refactor: add class dedicated to global paths

recyclarr
Robert Dailey 3 years ago
parent 17fec13107
commit f1e9b4f507

@ -0,0 +1,13 @@
using System;
using System.IO;
namespace Trash
{
internal static class AppPaths
{
public static string AppDataPath { get; } =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "trash-updater");
public static string DefaultConfigPath { get; } = Path.Join(AppContext.BaseDirectory, "trash.yml");
}
}

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
@ -70,7 +69,7 @@ namespace Trash.Command
[CommandOption("config", 'c', Description =
"One or more YAML config files to use. All configs will be used and settings are additive. " +
"If not specified, the script will look for `trash.yml` in the same directory as the executable.")]
public List<string> Config { get; [UsedImplicitly] set; } = new() {DefaultConfigPath};
public List<string> Config { get; [UsedImplicitly] set; } = new() {AppPaths.DefaultConfigPath};
private void SetupLogging()
{

@ -7,7 +7,6 @@ using CliFx.Infrastructure;
using Common;
using JetBrains.Annotations;
using Serilog;
using Trash.Command;
namespace Trash.CreateConfig
{
@ -29,7 +28,7 @@ namespace Trash.CreateConfig
"Path where the new YAML file should be created. Must include the filename (e.g. path/to/config.yml). " +
"File must not already exist. If not specified, uses the default path of `trash.yml` right next to the " +
"executable.")]
public string Path { get; [UsedImplicitly] set; } = ServiceCommand.DefaultConfigPath;
public string Path { get; [UsedImplicitly] set; } = AppPaths.DefaultConfigPath;
public ValueTask ExecuteAsync(IConsole console)
{

Loading…
Cancel
Save