diff --git a/starsky/starsky.feature.webhtmlpublish/Helpers/PublishCli.cs b/starsky/starsky.feature.webhtmlpublish/Helpers/PublishCli.cs
index cbcb9b1cb2..82a72a5b70 100644
--- a/starsky/starsky.feature.webhtmlpublish/Helpers/PublishCli.cs
+++ b/starsky/starsky.feature.webhtmlpublish/Helpers/PublishCli.cs
@@ -11,100 +11,112 @@
using starsky.foundation.storage.Models;
using starsky.foundation.storage.Storage;
-namespace starsky.feature.webhtmlpublish.Helpers
+namespace starsky.feature.webhtmlpublish.Helpers;
+
+public class PublishCli
{
- public class PublishCli
+ private readonly AppSettings _appSettings;
+ private readonly ArgsHelper _argsHelper;
+ private readonly IConsole _console;
+ private readonly IStorage _hostFileSystemStorage;
+ private readonly IWebLogger _logger;
+ private readonly IPublishPreflight _publishPreflight;
+ private readonly IWebHtmlPublishService _publishService;
+ private readonly ISelectorStorage _storageSelector;
+ private readonly IStorage _subPathStorage;
+
+ public PublishCli(ISelectorStorage storageSelector, IPublishPreflight publishPreflight,
+ IWebHtmlPublishService publishService, AppSettings appSettings, IConsole console,
+ IWebLogger logger)
{
- private readonly IPublishPreflight _publishPreflight;
- private readonly IWebHtmlPublishService _publishService;
- private readonly AppSettings _appSettings;
- private readonly IConsole _console;
- private readonly ArgsHelper _argsHelper;
- private readonly IStorage _hostFileSystemStorage;
- private readonly IStorage _subPathStorage;
- private readonly IWebLogger _logger;
- private readonly ISelectorStorage _storageSelector;
-
- public PublishCli(ISelectorStorage storageSelector, IPublishPreflight publishPreflight,
- IWebHtmlPublishService publishService, AppSettings appSettings, IConsole console, IWebLogger logger)
+ _publishPreflight = publishPreflight;
+ _publishService = publishService;
+ _appSettings = appSettings;
+ _console = console;
+ _argsHelper = new ArgsHelper(appSettings, console);
+ _hostFileSystemStorage =
+ storageSelector.Get(SelectorStorage.StorageServices.HostFilesystem);
+ _subPathStorage = storageSelector.Get(SelectorStorage.StorageServices.SubPath);
+ _storageSelector = storageSelector;
+ _logger = logger;
+ }
+
+ ///
+ /// Command Line Helper to server WebHtml Content
+ ///
+ /// arguments to adjust settings, see starskywebhtml/readme.md for more details
+ /// void
+ public async Task Publisher(string[] args)
+ {
+ _appSettings.Verbose = ArgsHelper.NeedVerbose(args);
+
+ if ( ArgsHelper.NeedHelp(args) )
+ {
+ _appSettings.ApplicationType = AppSettings.StarskyAppType.WebHtml;
+ _argsHelper.NeedHelpShowDialog();
+ return;
+ }
+
+ var inputFullPath = _argsHelper.GetPathFormArgs(args, false);
+ if ( string.IsNullOrWhiteSpace(inputFullPath) )
{
- _publishPreflight = publishPreflight;
- _publishService = publishService;
- _appSettings = appSettings;
- _console = console;
- _argsHelper = new ArgsHelper(appSettings, console);
- _hostFileSystemStorage = storageSelector.Get(SelectorStorage.StorageServices.HostFilesystem);
- _subPathStorage = storageSelector.Get(SelectorStorage.StorageServices.SubPath);
- _storageSelector = storageSelector;
- _logger = logger;
+ _console.WriteLine("Please use the -p to add a path first");
+ return;
}
- ///
- /// Command Line Helper to server WebHtml Content
- ///
- /// arguments to adjust settings, see starskywebhtml/readme.md for more details
- /// void
- public async Task Publisher(string[] args)
+ if ( _hostFileSystemStorage.IsFolderOrFile(inputFullPath) !=
+ FolderOrFileModel.FolderOrFileTypeList.Folder )
{
- _appSettings.Verbose = ArgsHelper.NeedVerbose(args);
-
- if ( ArgsHelper.NeedHelp(args) )
- {
- _appSettings.ApplicationType = AppSettings.StarskyAppType.WebHtml;
- _argsHelper.NeedHelpShowDialog();
- return;
- }
-
- var inputFullPath = _argsHelper.GetPathFormArgs(args, false);
- if ( string.IsNullOrWhiteSpace(inputFullPath) )
- {
- _console.WriteLine("Please use the -p to add a path first");
- return;
- }
-
- if ( _hostFileSystemStorage.IsFolderOrFile(inputFullPath) !=
- FolderOrFileModel.FolderOrFileTypeList.Folder )
- {
- _console.WriteLine("Please add a valid folder: " + inputFullPath + ". " +
- "This folder is not found");
- return;
- }
-
- var settingsFullFilePath = Path.Combine(inputFullPath, "_settings.json");
- if ( _hostFileSystemStorage.ExistFile(settingsFullFilePath) )
- {
- _console.WriteLine($"You have already run this program for this folder remove the " +
- $"_settings.json first and try it again");
- return;
- }
-
- var itemName = _publishPreflight.GetNameConsole(inputFullPath, args);
-
- if ( _appSettings.IsVerbose() )
- {
- _console.WriteLine("Name: " + itemName);
- _console.WriteLine("inputPath " + inputFullPath);
- }
-
- // used in this session to find the photos back
- // outside the webRoot of iStorage
- _appSettings.StorageFolder = inputFullPath;
-
- // use relative to StorageFolder
- var listOfFiles = _subPathStorage.GetAllFilesInDirectory("/")
- .Where(ExtensionRolesHelper.IsExtensionExifToolSupported).ToList();
-
- var fileIndexList = await new ReadMeta(_subPathStorage, _appSettings, null!, _logger)
- .ReadExifAndXmpFromFileAddFilePathHashAsync(listOfFiles);
-
- // todo introduce selector
- var profileName = new PublishPreflight(_appSettings, _console, _storageSelector, _logger)
- .GetPublishProfileNameByIndex(0);
-
- await _publishService.RenderCopy(fileIndexList, profileName,
- itemName, inputFullPath, true);
-
- _console.WriteLine("publish done");
+ _console.WriteLine("Please add a valid folder: " + inputFullPath + ". " +
+ "This folder is not found");
+ return;
}
+
+ var settingsFullFilePath = Path.Combine(inputFullPath, "_settings.json");
+ if ( _hostFileSystemStorage.ExistFile(settingsFullFilePath) )
+ {
+ _console.WriteLine($"You have already run this program for this folder remove the " +
+ $"_settings.json first and try it again");
+ return;
+ }
+
+ var itemName = _publishPreflight.GetNameConsole(inputFullPath, args);
+
+ if ( _appSettings.IsVerbose() )
+ {
+ _console.WriteLine("Name: " + itemName);
+ _console.WriteLine("inputPath " + inputFullPath);
+ }
+
+ // used in this session to find the photos back
+ // outside the webRoot of iStorage
+ _appSettings.StorageFolder = inputFullPath;
+
+ // use relative to StorageFolder
+ var listOfFiles = _subPathStorage.GetAllFilesInDirectory("/")
+ .Where(ExtensionRolesHelper.IsExtensionExifToolSupported).ToList();
+
+ var fileIndexList = await new ReadMeta(_subPathStorage, _appSettings, null!, _logger)
+ .ReadExifAndXmpFromFileAddFilePathHashAsync(listOfFiles);
+
+ var publishPreflight =
+ new PublishPreflight(_appSettings, _console, _storageSelector, _logger);
+ var profileName = ArgsHelper.GetProfile(args);
+
+ if ( publishPreflight.GetPublishProfileKey(profileName) != profileName )
+ {
+ profileName = publishPreflight.GetPublishProfileNameByIndex(0);
+ _console.WriteLine(
+ $"Profile not found, uses default {profileName} use --profile to select one");
+ }
+ else
+ {
+ _console.WriteLine("Running profile: " + profileName);
+ }
+
+ await _publishService.RenderCopy(fileIndexList, profileName,
+ itemName, inputFullPath, true);
+
+ _console.WriteLine("publish done");
}
}
diff --git a/starsky/starsky.feature.webhtmlpublish/Services/PublishPreflight.cs b/starsky/starsky.feature.webhtmlpublish/Services/PublishPreflight.cs
index b24076bb78..1f77dfa831 100644
--- a/starsky/starsky.feature.webhtmlpublish/Services/PublishPreflight.cs
+++ b/starsky/starsky.feature.webhtmlpublish/Services/PublishPreflight.cs
@@ -11,146 +11,152 @@
using starsky.foundation.storage.Interfaces;
using starsky.foundation.storage.Storage;
-namespace starsky.feature.webhtmlpublish.Services
+namespace starsky.feature.webhtmlpublish.Services;
+
+[Service(typeof(IPublishPreflight), InjectionLifetime = InjectionLifetime.Scoped)]
+public class PublishPreflight : IPublishPreflight
{
- [Service(typeof(IPublishPreflight), InjectionLifetime = InjectionLifetime.Scoped)]
- public class PublishPreflight : IPublishPreflight
- {
- private readonly AppSettings _appSettings;
- private readonly IConsole _console;
- private readonly IWebLogger _logger;
- private readonly IStorage _hostStorage;
+ private readonly AppSettings _appSettings;
+ private readonly IConsole _console;
+ private readonly IStorage _hostStorage;
+ private readonly IWebLogger _logger;
- public PublishPreflight(AppSettings appSettings, IConsole console,
- ISelectorStorage selectorStorage, IWebLogger logger)
- {
- _appSettings = appSettings;
- _console = console;
- _logger = logger;
- _hostStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
- }
+ public PublishPreflight(AppSettings appSettings, IConsole console,
+ ISelectorStorage selectorStorage, IWebLogger logger)
+ {
+ _appSettings = appSettings;
+ _console = console;
+ _logger = logger;
+ _hostStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
+ }
- public List> GetPublishProfileNames()
- {
- var returnList = new List>();
- if ( _appSettings.PublishProfiles == null || _appSettings.PublishProfiles.Count == 0 )
- {
- return returnList;
- }
+ ///
+ /// Check if the profile is valid
+ ///
+ /// profile key
+ /// (bool and list of errors)
+ public Tuple> IsProfileValid(
+ string publishProfileName)
+ {
+ var profiles = _appSettings.PublishProfiles!
+ .FirstOrDefault(p => p.Key == publishProfileName);
+ return IsProfileValid(profiles);
+ }
- var i = 0;
- foreach ( var profile in _appSettings.PublishProfiles )
- {
- returnList.Add(new Tuple(i, profile.Key));
- i++;
- }
+ ///
+ /// Get all publish profile names
+ ///
+ /// (string: name, bool: isValid)
+ public IEnumerable> GetAllPublishProfileNames()
+ {
+ return _appSettings.PublishProfiles!.Select(p =>
+ new KeyValuePair(
+ p.Key, IsProfileValid(p).Item1));
+ }
- return returnList;
- }
+ public List GetPublishProfileName(string publishProfileName)
+ {
+ return _appSettings.PublishProfiles!
+ .FirstOrDefault(p => p.Key == publishProfileName).Value;
+ }
- ///
- /// Check if the profile is valid
- ///
- /// profile key
- /// (bool and list of errors)
- public Tuple> IsProfileValid(
- string publishProfileName)
+ ///
+ /// Get the name by 1. -n or --name argument
+ /// Or 2. By user input
+ /// or 3. By user input and press enter to use the folder name
+ ///
+ /// full filepath to give default user input option
+ /// argument list
+ /// name, nothing is string.empty
+ public string GetNameConsole(string inputPath, IReadOnlyList args)
+ {
+ var name = ArgsHelper.GetName(args);
+ if ( !string.IsNullOrWhiteSpace(name) )
{
- var profiles = _appSettings.PublishProfiles!
- .FirstOrDefault(p => p.Key == publishProfileName);
- return IsProfileValid(profiles);
+ return name;
}
- ///
- /// Check if the profile is valid
- ///
- /// profile object
- /// (bool and list of errors)
- internal Tuple> IsProfileValid(
- KeyValuePair> profiles)
- {
- if ( profiles.Key == null || profiles.Value == null )
- {
- return new Tuple>(false,
- new List { "Profile not found" });
- }
+ var suggestedInput = Path.GetFileName(inputPath);
- var errors = new List();
- foreach ( var profile in profiles.Value )
- {
- if ( string.IsNullOrEmpty(profile.Path) )
- {
- continue;
- }
-
- if ( profile.ContentType == TemplateContentType.Html
- && !new ParseRazor(_hostStorage, _logger).Exist(profile.Template) )
- {
- errors.Add($"View Path {profile.Template} should exists");
- continue;
- }
-
- if ( !_hostStorage.ExistFile(profile.Path) && (
- profile.ContentType == TemplateContentType.Jpeg
- || profile.ContentType == TemplateContentType.OnlyFirstJpeg ) )
- {
- errors.Add($"Image Path {profile.Path} should exists");
- }
- }
+ _console.WriteLine("\nWhat is the name of the item? (for: " + suggestedInput +
+ " press Enter)\n ");
+ name = _console.ReadLine();
- return new Tuple>(errors.Count == 0, errors);
+ if ( string.IsNullOrEmpty(name) )
+ {
+ name = suggestedInput;
}
- ///
- /// Get all publish profile names
- ///
- /// (string: name, bool: isValid)
- public IEnumerable> GetAllPublishProfileNames()
+ return name.Trim();
+ }
+
+ public List> GetPublishProfileNames()
+ {
+ var returnList = new List>();
+ if ( _appSettings.PublishProfiles == null || _appSettings.PublishProfiles.Count == 0 )
{
- return _appSettings.PublishProfiles!.Select(p =>
- new KeyValuePair(
- p.Key, IsProfileValid(p).Item1));
+ return returnList;
}
- public List GetPublishProfileName(string publishProfileName)
+ var i = 0;
+ foreach ( var profile in _appSettings.PublishProfiles )
{
- return _appSettings.PublishProfiles!
- .FirstOrDefault(p => p.Key == publishProfileName).Value;
+ returnList.Add(new Tuple(i, profile.Key));
+ i++;
}
- public string GetPublishProfileNameByIndex(int index)
+ return returnList;
+ }
+
+ ///
+ /// Check if the profile is valid
+ ///
+ /// profile object
+ /// (bool and list of errors)
+ internal Tuple> IsProfileValid(
+ KeyValuePair> profiles)
+ {
+ if ( profiles.Key == null || profiles.Value == null )
{
- return _appSettings.PublishProfiles!.ElementAtOrDefault(index).Key;
+ return new Tuple>(false,
+ new List { "Profile not found" });
}
- ///
- /// Get the name by 1. -n or --name argument
- /// Or 2. By user input
- /// or 3. By user input and press enter to use the folder name
- ///
- /// full filepath to give default user input option
- /// argument list
- /// name, nothing is string.empty
- public string GetNameConsole(string inputPath, IReadOnlyList args)
+ var errors = new List();
+ foreach ( var profile in profiles.Value )
{
- var name = ArgsHelper.GetName(args);
- if ( !string.IsNullOrWhiteSpace(name) )
+ if ( string.IsNullOrEmpty(profile.Path) )
{
- return name;
+ continue;
}
- var suggestedInput = Path.GetFileName(inputPath);
-
- _console.WriteLine("\nWhat is the name of the item? (for: " + suggestedInput +
- " press Enter)\n ");
- name = _console.ReadLine();
-
- if ( string.IsNullOrEmpty(name) )
+ if ( profile.ContentType == TemplateContentType.Html
+ && !new ParseRazor(_hostStorage, _logger).Exist(profile.Template) )
{
- name = suggestedInput;
+ errors.Add($"View Path {profile.Template} should exists");
+ continue;
}
- return name.Trim();
+ if ( !_hostStorage.ExistFile(profile.Path) && (
+ profile.ContentType == TemplateContentType.Jpeg
+ || profile.ContentType == TemplateContentType.OnlyFirstJpeg ) )
+ {
+ errors.Add($"Image Path {profile.Path} should exists");
+ }
}
+
+ return new Tuple>(errors.Count == 0, errors);
+ }
+
+ public string GetPublishProfileKey(string publishProfileName)
+ {
+ var key = _appSettings.PublishProfiles!
+ .FirstOrDefault(p => p.Key == publishProfileName).Key;
+ return key;
+ }
+
+ public string GetPublishProfileNameByIndex(int index)
+ {
+ return _appSettings.PublishProfiles!.ElementAtOrDefault(index).Key;
}
}
diff --git a/starsky/starsky.foundation.platform/Helpers/ArgsHelper.cs b/starsky/starsky.foundation.platform/Helpers/ArgsHelper.cs
index d531e94c27..fd7a23df46 100644
--- a/starsky/starsky.foundation.platform/Helpers/ArgsHelper.cs
+++ b/starsky/starsky.foundation.platform/Helpers/ArgsHelper.cs
@@ -5,1015 +5,1043 @@
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using starsky.foundation.platform.Interfaces;
using starsky.foundation.platform.Models;
using starsky.foundation.platform.Services;
-namespace starsky.foundation.platform.Helpers
+namespace starsky.foundation.platform.Helpers;
+
+public sealed class ArgsHelper
{
- public sealed class ArgsHelper
+ private const string PathCommandLineArgLong = "--path";
+
+ ///
+ /// AppSettings
+ ///
+ private readonly AppSettings _appSettings = new();
+
+ ///
+ /// Console abstraction, use this instead of Console
+ ///
+ private readonly IConsole _console = new ConsoleWrapper();
+
+ ///
+ /// name of the env__ (__=:) use this order as 'LongNameList' and 'ShortNameList'
+ ///
+ public readonly IEnumerable EnvNameList = new List
{
- // Table of Content
-
- // -j > free
- // -k > free
- // -l > free
- // -q > free
- // -w > free
- // -y > free
- // -z > free
- // --verbose -v
- // --databasetype -d
- // --connection -c
- // --basepath -b
- // --thumbnailtempfolder -f
- // --tempfolder -tf
- // --exiftoolpath -e
- // --help -h
- // --index -i
- // --path -p
- // --subpath -s
- // --subpathrelative -g
- // --thumbnail -t
- // --orphanfolder -o
- // --move -m
- // --all -a
- // --recruisive -r
- // -rf --readonlyfolders // no need to use in cli/importercli
- // -u --structure
- // -n --name
- // -x --clean
- // --colorclass (no shorthand)
-
- ///
- /// Simple injection
- ///
- public ArgsHelper()
+ "app__DatabaseType",
+ "app__DatabaseConnection",
+ "app__StorageFolder",
+ "app__ThumbnailTempFolder",
+ "app__ExifToolPath",
+ "app__Structure",
+ "app__subpathrelative",
+ "app__ExifToolImportXmpCreate",
+ "app__TempFolder",
+ "app__DependenciesFolder"
+ }.AsReadOnly();
+
+ ///
+ /// Long input args, use this order as 'ShortNameList' and 'EnvNameList'
+ ///
+ public readonly IEnumerable LongNameList = new List
{
+ "--databasetype",
+ "--connection",
+ "--basepath",
+ "--thumbnailtempfolder",
+ "--exiftoolpath",
+ "--structure",
+ "--subpathrelative",
+ "--clean",
+ "--tempfolder",
+ "--dependencies"
}
+ .AsReadOnly();
- ///
- /// Use with appSettings
- ///
- /// appSettings
- /// Console log
- public ArgsHelper(AppSettings appSettings, IConsole? console = null)
+ ///
+ /// short input args, use the same order as 'LongNameList' and 'EnvNameList'
+ ///
+ public readonly IEnumerable ShortNameList = new List
+ {
+ "-d",
+ "-c",
+ "-b",
+ "-f",
+ "-e",
+ "-u",
+ "-g",
+ "-x",
+ "-tf",
+ "-dep"
+ }.AsReadOnly();
+ // Table of Content
+
+ // -j > free
+ // -k > free
+ // -l > free
+ // -q > free
+ // -w > free
+ // -y > free
+ // -z > free
+ // --verbose -v
+ // --databasetype -d
+ // --connection -c
+ // --basepath -b
+ // --thumbnailtempfolder -f
+ // --tempfolder -tf
+ // --exiftoolpath -e
+ // --help -h
+ // --index -i
+ // --path -p
+ // --subpath -s
+ // --subpathrelative -g
+ // --thumbnail -t
+ // --orphanfolder -o
+ // --move -m
+ // --all -a
+ // --recruisive -r
+ // -rf --readonlyfolders // no need to use in cli/importercli
+ // -u --structure
+ // -n --name
+ // -x --clean
+ // --colorclass (no shorthand)
+
+ ///
+ /// Simple injection
+ ///
+ public ArgsHelper()
+ {
+ }
+
+ ///
+ /// Use with appSettings
+ ///
+ /// appSettings
+ /// Console log
+ public ArgsHelper(AppSettings appSettings, IConsole? console = null)
+ {
+ _appSettings = appSettings;
+ if ( console != null )
{
- _appSettings = appSettings;
- if ( console != null )
- {
- _console = console;
- }
+ _console = console;
}
+ }
- ///
- /// Console abstraction, use this instead of Console
- ///
- private readonly IConsole _console = new ConsoleWrapper();
-
- ///
- /// AppSettings
- ///
- private readonly AppSettings _appSettings = new AppSettings();
-
- ///
- /// Show debug information
- ///
- /// input args
- ///
- public static bool NeedVerbose(IReadOnlyList args)
+ ///
+ /// Show debug information
+ ///
+ /// input args
+ ///
+ public static bool NeedVerbose(IReadOnlyList args)
+ {
+ var needDebug = false;
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- var needDebug = false;
- for ( var arg = 0; arg < args.Count; arg++ )
+ if ( ( args[arg].Equals("--verbose", StringComparison.CurrentCultureIgnoreCase)
+ || args[arg].Equals("-v", StringComparison.CurrentCultureIgnoreCase) )
+ && arg + 1 != args.Count
+ && bool.TryParse(args[arg + 1], out var needDebugParsed) )
{
- if ( ( args[arg].Equals("--verbose", StringComparison.CurrentCultureIgnoreCase)
- || args[arg].Equals("-v", StringComparison.CurrentCultureIgnoreCase) )
- && ( arg + 1 ) != args.Count
- && bool.TryParse(args[arg + 1], out var needDebugParsed) )
- {
- needDebug = needDebugParsed;
- }
-
- if ( ( args[arg].Equals("--verbose", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-v", StringComparison.CurrentCultureIgnoreCase) ) )
- {
- needDebug = true;
- }
+ needDebug = needDebugParsed;
}
- return needDebug;
- }
-
- ///
- /// short input args, use the same order as 'LongNameList' and 'EnvNameList'
- ///
- public readonly IEnumerable ShortNameList = new List
- {
- "-d",
- "-c",
- "-b",
- "-f",
- "-e",
- "-u",
- "-g",
- "-x",
- "-tf",
- "-dep"
- }.AsReadOnly();
-
- ///
- /// Long input args, use this order as 'ShortNameList' and 'EnvNameList'
- ///
- public readonly IEnumerable LongNameList = new List
- {
- "--databasetype",
- "--connection",
- "--basepath",
- "--thumbnailtempfolder",
- "--exiftoolpath",
- "--structure",
- "--subpathrelative",
- "--clean",
- "--tempfolder",
- "--dependencies"
- }
- .AsReadOnly();
-
- ///
- /// name of the env__ (__=:) use this order as 'LongNameList' and 'ShortNameList'
- ///
- public readonly IEnumerable EnvNameList = new List
- {
- "app__DatabaseType",
- "app__DatabaseConnection",
- "app__StorageFolder",
- "app__ThumbnailTempFolder",
- "app__ExifToolPath",
- "app__Structure",
- "app__subpathrelative",
- "app__ExifToolImportXmpCreate",
- "app__TempFolder",
- "app__DependenciesFolder"
- }.AsReadOnly();
-
- ///
- /// SetEnvironmentByArgs
- ///
- ///
- public void SetEnvironmentByArgs(IReadOnlyList args)
- {
- var shortNameList = ShortNameList.ToArray();
- var longNameList = LongNameList.ToArray();
- var envNameList = EnvNameList.ToArray();
- for ( var i = 0; i < ShortNameList.Count(); i++ )
+ if ( args[arg].Equals("--verbose", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-v", StringComparison.CurrentCultureIgnoreCase) )
{
- for ( var arg = 0; arg < args.Count; arg++ )
- {
- if ( ( args[arg].Equals(longNameList[i],
- StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals(shortNameList[i],
- StringComparison.CurrentCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count )
- {
- Environment.SetEnvironmentVariable(envNameList[i], args[arg + 1]);
- }
- }
+ needDebug = true;
}
}
- ///
- /// Set Environment Variables to appSettings (not used in .net core), used by framework app
- ///
- /// use with _appSettings
- public void SetEnvironmentToAppSettings()
- {
- if ( _appSettings == null )
- {
- throw new FieldAccessException("AppSettings cannot be null at start");
- }
+ return needDebug;
+ }
- var envNameList = EnvNameList.ToArray();
- foreach ( var envUnderscoreName in envNameList )
+ ///
+ /// SetEnvironmentByArgs
+ ///
+ ///
+ public void SetEnvironmentByArgs(IReadOnlyList args)
+ {
+ var shortNameList = ShortNameList.ToArray();
+ var longNameList = LongNameList.ToArray();
+ var envNameList = EnvNameList.ToArray();
+ for ( var i = 0; i < ShortNameList.Count(); i++ )
+ {
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- var envValue = Environment.GetEnvironmentVariable(envUnderscoreName);
- var envName = envUnderscoreName.Replace("app__", string.Empty);
- if ( !string.IsNullOrEmpty(envValue) )
+ if ( ( args[arg].Equals(longNameList[i],
+ StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals(shortNameList[i],
+ StringComparison.CurrentCultureIgnoreCase) ) &&
+ arg + 1 != args.Count )
{
- var propertyObject = _appSettings.GetType().GetProperty(envName);
- if ( propertyObject == null )
- {
- continue;
- }
-
- var type = propertyObject.PropertyType;
-
- // for enums
- if ( propertyObject.PropertyType.IsEnum )
- {
- var envTypedObject = Enum.Parse(type, envValue);
- propertyObject.SetValue(_appSettings, envTypedObject, null);
- continue;
- }
-
- dynamic envTypedDynamic = Convert.ChangeType(envValue, type);
- propertyObject.SetValue(_appSettings, envTypedDynamic, null);
+ Environment.SetEnvironmentVariable(envNameList[i], args[arg + 1]);
}
}
}
+ }
+ ///
+ /// Set Environment Variables to appSettings (not used in .net core), used by framework app
+ ///
+ /// use with _appSettings
+ public void SetEnvironmentToAppSettings()
+ {
+ if ( _appSettings == null )
+ {
+ throw new FieldAccessException("AppSettings cannot be null at start");
+ }
- ///
- /// Based on args get the -h or --help commandline input
- ///
- /// args input
- /// bool, true if --help
- public static bool NeedHelp(IReadOnlyList args)
+ var envNameList = EnvNameList.ToArray();
+ foreach ( var envUnderscoreName in envNameList )
{
- var needHelp = false;
- for ( var arg = 0; arg < args.Count; arg++ )
+ var envValue = Environment.GetEnvironmentVariable(envUnderscoreName);
+ var envName = envUnderscoreName.Replace("app__", string.Empty);
+ if ( !string.IsNullOrEmpty(envValue) )
{
- if ( ( args[arg].Equals("--help", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-h", StringComparison.CurrentCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count
- && bool.TryParse(args[arg + 1], out var needHelp2) && needHelp2 )
+ var propertyObject = _appSettings.GetType().GetProperty(envName);
+ if ( propertyObject == null )
{
- needHelp = true;
+ continue;
}
- if ( args[arg].Equals("--help", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-h", StringComparison.CurrentCultureIgnoreCase) )
+ var type = propertyObject.PropertyType;
+
+ // for enums
+ if ( propertyObject.PropertyType.IsEnum )
{
- needHelp = true;
+ var envTypedObject = Enum.Parse(type, envValue);
+ propertyObject.SetValue(_appSettings, envTypedObject, null);
+ continue;
}
- }
- return needHelp;
+ dynamic envTypedDynamic = Convert.ChangeType(envValue, type);
+ propertyObject.SetValue(_appSettings, envTypedDynamic, null);
+ }
}
+ }
- ///
- /// Show Help dialog
- ///
- /// use appSettings
- [SuppressMessage("Usage",
- "S2068:password detected here, make sure this is not a hard-coded credential")]
- public void NeedHelpShowDialog()
+
+ ///
+ /// Based on args get the -h or --help commandline input
+ ///
+ /// args input
+ /// bool, true if --help
+ public static bool NeedHelp(IReadOnlyList args)
+ {
+ var needHelp = false;
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- if ( _appSettings == null )
+ if ( ( args[arg].Equals("--help", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-h", StringComparison.CurrentCultureIgnoreCase) ) &&
+ arg + 1 != args.Count
+ && bool.TryParse(args[arg + 1], out var needHelp2) && needHelp2 )
{
- throw new FieldAccessException("AppSettings Cannot be Null");
+ needHelp = true;
}
- _console.WriteLine("Starsky " + _appSettings.ApplicationType + " Cli ~ Help:");
- _console.WriteLine("--help or -h == help (this window)");
-
- switch ( _appSettings.ApplicationType )
+ if ( args[arg].Equals("--help", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-h", StringComparison.CurrentCultureIgnoreCase) )
{
- case AppSettings.StarskyAppType.Thumbnail:
-
- _console.WriteLine("-t == enable thumbnail (default true)");
- _console.WriteLine("--path or (short) -p == parameter: (string) ; " +
- "'full path', only child items of the database folder are supported," +
- "search and replace first part of the filename, '/', use '-p' for current directory ");
- _console.WriteLine(
- "--subpath or -s == parameter: (string) ; relative path in the database");
- _console.WriteLine(
- "--subpathrelative or -g == Overwrite sub-path to use relative days to select a folder" +
- ", use for example '1' to select yesterday. (structure is required for this)");
- _console.WriteLine("-p, -s, -g == on of those are required for this feature");
-
- _console.WriteLine("recursive is enabled by default");
- break;
- case AppSettings.StarskyAppType.MetaThumbnail:
- _console.WriteLine("--path or -p == parameter: (string) ; " +
- "'full path', only child items of the database folder are supported," +
- "search and replace first part of the filename, '/', use '-p' for current directory ");
- _console.WriteLine(
- "--subpath or -s == parameter: (string) ; relative path in the database");
- _console.WriteLine(
- "--subpathrelative or -g == Overwrite sub-path to use relative days to select a folder" +
- ", use for example '1' to select yesterday. (structure is required)");
- _console.WriteLine("-p, -s, -g == select one of those before starting");
-
- _console.WriteLine("recursive is enabled by default");
- break;
- case AppSettings.StarskyAppType.Admin:
- _console.WriteLine("--name or -n == string ; username / email");
- _console.WriteLine("--password == string ; password");
- break;
- case AppSettings.StarskyAppType.Geo:
- // When this change please update ./readme.md
- _console.WriteLine("--path or -p == parameter: (string) ; " +
- "without addition is current directory, full path (all locations are supported) ");
- _console.WriteLine(
- "--subpath or -s == parameter: (string) ; relative path in the database ");
- _console.WriteLine(
- "--subpathrelative or -g == Overwrite subpath to use relative days to select a folder" +
- ", use for example '1' to select yesterday. (structure is required)");
- _console.WriteLine("-p, -s, -g == you need to select one of those tags");
- _console.WriteLine("--all or -a == overwrite reverse geotag location tags " +
- "(default: false / ignore already taged files) ");
- _console.WriteLine(
- "--index or -i == parameter: (bool) ; gpx feature to index geo location, default true");
- break;
- case AppSettings.StarskyAppType.WebHtml:
- // When this change please update ./readme.md
- _console.WriteLine(
- "--path or -p == parameter: (string) ; full path (select a folder), " +
- "use '-p' for current directory");
- _console.WriteLine("--name or -n == parameter: (string) ; name of blog item ");
- break;
- case AppSettings.StarskyAppType.Importer:
- // When this change please update ./readme.md
- _console.WriteLine("--path or -p == parameter: (string) ; full path");
- _console.WriteLine(
- " can be an folder or file, use '-p' for current directory");
- _console.WriteLine(" for multiple items use dot comma (;) " +
- "to split and quotes (\") around the input string");
- _console.WriteLine(
- "--move or -m == delete file after importing (default false / copy file)");
- _console.WriteLine("--recursive or -r == Import Directory recursive " +
- "(default: false / only the selected folder) ");
- _console.WriteLine(
- "--structure == overwrite app-settings with file-directory structure " +
- "based on exif and filename create datetime");
- _console.WriteLine(
- "--index or -i == parameter: (bool) ; indexing, false is always copy," +
- " true is check if exist in db, default true");
- _console.WriteLine(
- "--clean or -x == true is to add a xmp sidecar file for raws, default true");
- _console.WriteLine(
- "--colorclass == update color-class to this number value, default don't change");
- break;
- case AppSettings.StarskyAppType.Sync:
- // When this change please update ./readme.md
- _console.WriteLine("--path or -p == parameter: (string) ; " +
- "'full path', only child items of the database folder are supported," +
- "search and replace first part of the filename, '/', use '-p' for current directory ");
- _console.WriteLine(
- "--subpath or -s == parameter: (string) ; relative path in the database");
- _console.WriteLine(
- "--subpathrelative or -g == Overwrite sub-path to use relative days to select a folder" +
- ", use for example '1' to select yesterday. (structure is required)");
- _console.WriteLine("-p, -s, -g == you need to select one of those tags");
- _console.WriteLine(
- "--index or -i == parameter: (bool) ; enable indexing, default true");
- _console.WriteLine(
- "--thumbnail or -t == parameter: (bool) ; enable thumbnail, default false");
- _console.WriteLine(
- "--clean or -x == parameter: (bool) ; enable checks in thumbnail-temp-folder" +
- " if thumbnails are needed, delete unused files");
- _console.WriteLine(
- "--orphanfolder or -o == To delete files without a parent folder " +
- "(heavy cpu usage), default false");
- _console.WriteLine("--verbose or -v == verbose, more detailed info");
- _console.WriteLine(
- "--databasetype or -d == Overwrite EnvironmentVariable for DatabaseType");
- _console.WriteLine(
- "--basepath or -b == Overwrite EnvironmentVariable for StorageFolder");
- _console.WriteLine(
- "--connection or -c == Overwrite EnvironmentVariable for DatabaseConnection");
- _console.WriteLine(
- "--thumbnailtempfolder or -f == Overwrite EnvironmentVariable for ThumbnailTempFolder");
- _console.WriteLine(
- "--exiftoolpath or -e == Overwrite EnvironmentVariable for ExifToolPath");
- break;
+ needHelp = true;
}
+ }
+
+ return needHelp;
+ }
- _console.WriteLine("--verbose or -v == verbose, more detailed info");
- _console.WriteLine(" use -v -help to show settings: ");
+ ///
+ /// Show Help dialog
+ ///
+ /// use appSettings
+ [SuppressMessage("Usage",
+ "S2068:password detected here, make sure this is not a hard-coded credential")]
+ public void NeedHelpShowDialog()
+ {
+ if ( _appSettings == null )
+ {
+ throw new FieldAccessException("AppSettings Cannot be Null");
+ }
- if ( !_appSettings.IsVerbose() )
- {
- return;
- }
+ _console.WriteLine("Starsky " + _appSettings.ApplicationType + " Cli ~ Help:");
+ _console.WriteLine("--help or -h == help (this window)");
- _console.WriteLine(string.Empty);
- _console.WriteLine("AppSettings: " + _appSettings.ApplicationType);
- _console.WriteLine("Database Type (-d --databasetype) " + _appSettings.DatabaseType);
- _console.WriteLine("DatabaseConnection (-c --connection) " +
- _appSettings.DatabaseConnection);
- _console.WriteLine($"StorageFolder (-b --basepath) {_appSettings.StorageFolder} ");
- _console.WriteLine(
- $"ThumbnailTempFolder (-f --thumbnailtempfolder) {_appSettings.ThumbnailTempFolder} ");
- _console.WriteLine($"ExifToolPath (-e --exiftoolpath) {_appSettings.ExifToolPath} ");
- _console.WriteLine("Structure (-u --structure) " + _appSettings.Structure);
- _console.WriteLine("CameraTimeZone " + _appSettings.CameraTimeZone);
- _console.WriteLine("Name " + _appSettings.Name);
- _console.WriteLine($"TempFolder {_appSettings.TempFolder} ");
- _console.WriteLine($"BaseDirectoryProject {_appSettings.BaseDirectoryProject} ");
- _console.WriteLine("ExiftoolSkipDownloadOnStartup " +
- _appSettings.ExiftoolSkipDownloadOnStartup);
- _console.WriteLine("GeoFilesSkipDownloadOnStartup " +
- _appSettings.GeoFilesSkipDownloadOnStartup);
-
- _console.WriteLine($"MaxDegreesOfParallelism {_appSettings.MaxDegreesOfParallelism} ");
-
- // OpenTelemetry
- if ( !string.IsNullOrEmpty(_appSettings.OpenTelemetry?.LogsEndpoint) )
- {
- _console.WriteLine($"LogsEndpoint {_appSettings.OpenTelemetry.LogsEndpoint} ");
- }
+ switch ( _appSettings.ApplicationType )
+ {
+ case AppSettings.StarskyAppType.Thumbnail:
- if ( !string.IsNullOrEmpty(_appSettings.OpenTelemetry?.MetricsEndpoint) )
- {
+ _console.WriteLine("-t == enable thumbnail (default true)");
+ _console.WriteLine("--path or (short) -p == parameter: (string) ; " +
+ "'full path', only child items of the database folder are supported," +
+ "search and replace first part of the filename, '/', use '-p' for current directory ");
_console.WriteLine(
- $"MetricsEndpoint {_appSettings.OpenTelemetry.MetricsEndpoint} ");
- }
-
- if ( !string.IsNullOrEmpty(_appSettings.OpenTelemetry?.TracesEndpoint) )
- {
- _console.WriteLine($"TracesEndpoint {_appSettings.OpenTelemetry.TracesEndpoint} ");
- }
+ "--subpath or -s == parameter: (string) ; relative path in the database");
+ _console.WriteLine(
+ "--subpathrelative or -g == Overwrite sub-path to use relative days to select a folder" +
+ ", use for example '1' to select yesterday. (structure is required for this)");
+ _console.WriteLine("-p, -s, -g == on of those are required for this feature");
+
+ _console.WriteLine("recursive is enabled by default");
+ break;
+ case AppSettings.StarskyAppType.MetaThumbnail:
+ _console.WriteLine("--path or -p == parameter: (string) ; " +
+ "'full path', only child items of the database folder are supported," +
+ "search and replace first part of the filename, '/', use '-p' for current directory ");
+ _console.WriteLine(
+ "--subpath or -s == parameter: (string) ; relative path in the database");
+ _console.WriteLine(
+ "--subpathrelative or -g == Overwrite sub-path to use relative days to select a folder" +
+ ", use for example '1' to select yesterday. (structure is required)");
+ _console.WriteLine("-p, -s, -g == select one of those before starting");
+
+ _console.WriteLine("recursive is enabled by default");
+ break;
+ case AppSettings.StarskyAppType.Admin:
+ _console.WriteLine("--name or -n == string ; username / email");
+ _console.WriteLine("--password == string ; password");
+ break;
+ case AppSettings.StarskyAppType.Geo:
+ // When this change please update ./readme.md
+ _console.WriteLine("--path or -p == parameter: (string) ; " +
+ "without addition is current directory, full path (all locations are supported) ");
+ _console.WriteLine(
+ "--subpath or -s == parameter: (string) ; relative path in the database ");
+ _console.WriteLine(
+ "--subpathrelative or -g == Overwrite subpath to use relative days to select a folder" +
+ ", use for example '1' to select yesterday. (structure is required)");
+ _console.WriteLine("-p, -s, -g == you need to select one of those tags");
+ _console.WriteLine("--all or -a == overwrite reverse geotag location tags " +
+ "(default: false / ignore already taged files) ");
+ _console.WriteLine(
+ "--index or -i == parameter: (bool) ; gpx feature to index geo location, default true");
+ break;
+ case AppSettings.StarskyAppType.WebHtml:
+ // When this change please update ./readme.md
+ _console.WriteLine(
+ "--path or -p == parameter: (string) ; full path (select a folder), " +
+ "use '-p' for current directory");
+ _console.WriteLine("--name or -n == parameter: (string) ; name of blog item ");
+ _console.WriteLine(
+ "--profile: (string) ; name of profile to select (default to first)");
+ break;
+ case AppSettings.StarskyAppType.Importer:
+ // When this change please update ./readme.md
+ _console.WriteLine("--path or -p == parameter: (string) ; full path");
+ _console.WriteLine(
+ " can be an folder or file, use '-p' for current directory");
+ _console.WriteLine(" for multiple items use dot comma (;) " +
+ "to split and quotes (\") around the input string");
+ _console.WriteLine(
+ "--move or -m == delete file after importing (default false / copy file)");
+ _console.WriteLine("--recursive or -r == Import Directory recursive " +
+ "(default: false / only the selected folder) ");
+ _console.WriteLine(
+ "--structure == overwrite app-settings with file-directory structure " +
+ "based on exif and filename create datetime");
+ _console.WriteLine(
+ "--index or -i == parameter: (bool) ; indexing, false is always copy," +
+ " true is check if exist in db, default true");
+ _console.WriteLine(
+ "--clean or -x == true is to add a xmp sidecar file for raws, default true");
+ _console.WriteLine(
+ "--colorclass == update color-class to this number value, default don't change");
+ break;
+ case AppSettings.StarskyAppType.Sync:
+ // When this change please update ./readme.md
+ _console.WriteLine("--path or -p == parameter: (string) ; " +
+ "'full path', only child items of the database folder are supported," +
+ "search and replace first part of the filename, '/', use '-p' for current directory ");
+ _console.WriteLine(
+ "--subpath or -s == parameter: (string) ; relative path in the database");
+ _console.WriteLine(
+ "--subpathrelative or -g == Overwrite sub-path to use relative days to select a folder" +
+ ", use for example '1' to select yesterday. (structure is required)");
+ _console.WriteLine("-p, -s, -g == you need to select one of those tags");
+ _console.WriteLine(
+ "--index or -i == parameter: (bool) ; enable indexing, default true");
+ _console.WriteLine(
+ "--thumbnail or -t == parameter: (bool) ; enable thumbnail, default false");
+ _console.WriteLine(
+ "--clean or -x == parameter: (bool) ; enable checks in thumbnail-temp-folder" +
+ " if thumbnails are needed, delete unused files");
+ _console.WriteLine(
+ "--orphanfolder or -o == To delete files without a parent folder " +
+ "(heavy cpu usage), default false");
+ _console.WriteLine("--verbose or -v == verbose, more detailed info");
+ _console.WriteLine(
+ "--databasetype or -d == Overwrite EnvironmentVariable for DatabaseType");
+ _console.WriteLine(
+ "--basepath or -b == Overwrite EnvironmentVariable for StorageFolder");
+ _console.WriteLine(
+ "--connection or -c == Overwrite EnvironmentVariable for DatabaseConnection");
+ _console.WriteLine(
+ "--thumbnailtempfolder or -f == Overwrite EnvironmentVariable for ThumbnailTempFolder");
+ _console.WriteLine(
+ "--exiftoolpath or -e == Overwrite EnvironmentVariable for ExifToolPath");
+ break;
+ }
- _console.Write("SyncIgnore ");
- foreach ( var rule in _appSettings.SyncIgnore )
- {
- _console.Write($"{rule}, ");
- }
+ _console.WriteLine("--verbose or -v == verbose, more detailed info");
+ _console.WriteLine(" use -v -help to show settings: ");
- _console.Write("\n");
+ if ( !_appSettings.IsVerbose() )
+ {
+ return;
+ }
- _console.Write("ImportIgnore ");
- foreach ( var rule in _appSettings.ImportIgnore )
- {
- _console.Write($"{rule}, ");
- }
+ _console.WriteLine(string.Empty);
+ _console.WriteLine("AppSettings: " + _appSettings.ApplicationType);
+ _console.WriteLine("Database Type (-d --databasetype) " + _appSettings.DatabaseType);
+ _console.WriteLine("DatabaseConnection (-c --connection) " +
+ _appSettings.DatabaseConnection);
+ _console.WriteLine($"StorageFolder (-b --basepath) {_appSettings.StorageFolder} ");
+ _console.WriteLine(
+ $"ThumbnailTempFolder (-f --thumbnailtempfolder) {_appSettings.ThumbnailTempFolder} ");
+ _console.WriteLine($"ExifToolPath (-e --exiftoolpath) {_appSettings.ExifToolPath} ");
+ _console.WriteLine("Structure (-u --structure) " + _appSettings.Structure);
+ _console.WriteLine("CameraTimeZone " + _appSettings.CameraTimeZone);
+ _console.WriteLine("Name " + _appSettings.Name);
+ _console.WriteLine($"TempFolder {_appSettings.TempFolder} ");
+ _console.WriteLine($"BaseDirectoryProject {_appSettings.BaseDirectoryProject} ");
+ _console.WriteLine("ExiftoolSkipDownloadOnStartup " +
+ _appSettings.ExiftoolSkipDownloadOnStartup);
+ _console.WriteLine("GeoFilesSkipDownloadOnStartup " +
+ _appSettings.GeoFilesSkipDownloadOnStartup);
+
+ _console.WriteLine($"MaxDegreesOfParallelism {_appSettings.MaxDegreesOfParallelism} ");
+
+ // OpenTelemetry
+ if ( !string.IsNullOrEmpty(_appSettings.OpenTelemetry?.LogsEndpoint) )
+ {
+ _console.WriteLine(
+ $"OpenTelemetry LogsEndpoint: {_appSettings.OpenTelemetry.LogsEndpoint} ");
+ }
- _console.Write("\n");
+ if ( !string.IsNullOrEmpty(_appSettings.OpenTelemetry?.MetricsEndpoint) )
+ {
+ _console.WriteLine(
+ $"OpenTelemetry MetricsEndpoint: {_appSettings.OpenTelemetry.MetricsEndpoint} ");
+ }
- if ( _appSettings.ApplicationType == AppSettings.StarskyAppType.Importer )
- {
- _console.WriteLine("Create xmp on import (ExifToolImportXmpCreate): " +
- _appSettings.ExifToolImportXmpCreate);
- }
+ if ( !string.IsNullOrEmpty(_appSettings.OpenTelemetry?.TracesEndpoint) )
+ {
+ _console.WriteLine(
+ $"OpenTelemetry TracesEndpoint: {_appSettings.OpenTelemetry.TracesEndpoint} ");
+ }
- if ( _appSettings.ApplicationType == AppSettings.StarskyAppType.WebFtp )
- {
- _console.WriteLine("WebFtp " + _appSettings.WebFtp);
- }
+ _console.Write("SyncIgnore ");
+ foreach ( var rule in _appSettings.SyncIgnore )
+ {
+ _console.Write($"{rule}, ");
+ }
- if ( _appSettings.ApplicationType == AppSettings.StarskyAppType.Admin )
- {
- _console.WriteLine("NoAccountLocalhost " + _appSettings.NoAccountLocalhost);
- }
+ _console.Write("\n");
- _console.WriteLine("-- Appsettings.json locations -- ");
+ _console.Write("ImportIgnore ");
+ foreach ( var rule in _appSettings.ImportIgnore )
+ {
+ _console.Write($"{rule}, ");
+ }
- var machineName = Environment.MachineName.ToLowerInvariant();
+ _console.Write("\n");
- _console.WriteLine(
- "Config is read in this order: (latest is applied over lower numbers)");
- _console.WriteLine(
- $"1. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings.json")}");
- _console.WriteLine(
- $"2. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings.default.json")}");
- _console.WriteLine(
- $"3. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings.patch.json")}");
- _console.WriteLine(
- $"4. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings." + machineName + ".json")}");
- _console.WriteLine(
- $"5. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings." + machineName + ".patch.json")}");
- _console.WriteLine(
- $"6. Environment variable: app__appsettingspath: {Environment.GetEnvironmentVariable("app__appsettingspath")}");
- _console.WriteLine("7. Specific environment variables for example app__storageFolder");
+ if ( _appSettings.ApplicationType == AppSettings.StarskyAppType.Importer )
+ {
+ _console.WriteLine("Create xmp on import (ExifToolImportXmpCreate): " +
+ _appSettings.ExifToolImportXmpCreate);
+ }
- AppSpecificHelp();
+ if ( _appSettings.ApplicationType == AppSettings.StarskyAppType.WebFtp )
+ {
+ _console.WriteLine("WebFtp " + _appSettings.WebFtp);
+ }
- ShowVersions();
+ if ( _appSettings.ApplicationType == AppSettings.StarskyAppType.Admin )
+ {
+ _console.WriteLine("NoAccountLocalhost " + _appSettings.NoAccountLocalhost);
}
- private void AppSpecificHelp()
+ _console.WriteLine("-- Appsettings.json locations -- ");
+
+ var machineName = Environment.MachineName.ToLowerInvariant();
+
+ _console.WriteLine(
+ "Config is read in this order: (latest is applied over lower numbers)");
+ _console.WriteLine(
+ $"1. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings.json")}");
+ _console.WriteLine(
+ $"2. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings.default.json")}");
+ _console.WriteLine(
+ $"3. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings.patch.json")}");
+ _console.WriteLine(
+ $"4. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings." + machineName + ".json")}");
+ _console.WriteLine(
+ $"5. {Path.Combine(_appSettings.BaseDirectoryProject, "appsettings." + machineName + ".patch.json")}");
+ _console.WriteLine(
+ $"6. Environment variable: app__appsettingspath: {Environment.GetEnvironmentVariable("app__appsettingspath")}");
+ _console.WriteLine("7. Specific environment variables for example app__storageFolder");
+
+ AppSpecificHelp();
+
+ ShowVersions();
+ }
+
+ private void AppSpecificHelp()
+ {
+ switch ( _appSettings.ApplicationType )
{
- switch ( _appSettings.ApplicationType )
- {
- case AppSettings.StarskyAppType.WebHtml:
- _console.WriteLine($"Config for {_appSettings.ApplicationType}");
- if ( _appSettings.PublishProfiles == null )
- {
- break;
- }
+ case AppSettings.StarskyAppType.WebHtml:
+ _console.WriteLine($"Config for {_appSettings.ApplicationType}");
+ if ( _appSettings.PublishProfiles == null )
+ {
+ break;
+ }
- foreach ( var publishProfiles in _appSettings.PublishProfiles )
+ foreach ( var publishProfiles in _appSettings.PublishProfiles )
+ {
+ _console.WriteLine($"ID: {publishProfiles.Key}");
+ foreach ( var publishProfile in publishProfiles.Value )
{
- _console.WriteLine($"ID: {publishProfiles.Key}");
- foreach ( var publishProfile in publishProfiles.Value )
- {
- _console.WriteLine("--- " +
- $"Path: {publishProfile.Path} " +
- $"Append: {publishProfile.Append} " +
- $"Copy: {publishProfile.Copy} " +
- $"Folder: {publishProfile.Folder} " +
- $"Prepend: {publishProfile.Prepend} " +
- $"Template: {publishProfile.Template} " +
- $"ContentType: {publishProfile.ContentType} " +
- $"MetaData: {publishProfile.MetaData} " +
- $"OverlayMaxWidth: {publishProfile.OverlayMaxWidth} " +
- $"SourceMaxWidth: {publishProfile.SourceMaxWidth} ");
- }
+ _console.WriteLine("--- " +
+ $"Path: {publishProfile.Path} " +
+ $"Append: {publishProfile.Append} " +
+ $"Copy: {publishProfile.Copy} " +
+ $"Folder: {publishProfile.Folder} " +
+ $"Prepend: {publishProfile.Prepend} " +
+ $"Template: {publishProfile.Template} " +
+ $"ContentType: {publishProfile.ContentType} " +
+ $"MetaData: {publishProfile.MetaData} " +
+ $"OverlayMaxWidth: {publishProfile.OverlayMaxWidth} " +
+ $"SourceMaxWidth: {publishProfile.SourceMaxWidth} ");
}
+ }
- break;
- }
+ break;
}
+ }
+
+ ///
+ /// Show in Console the .NET Version (Runtime) and Starsky Version
+ /// @see: https://stackoverflow.com/a/58136318
+ ///
+ private void ShowVersions()
+ {
+ var version = RuntimeInformation.FrameworkDescription;
+ _console.WriteLine($".NET Version - {version}");
+ _console.WriteLine($"Starsky Version - {_appSettings.AppVersion} " +
+ "- build at: " +
+ DateAssembly.GetBuildDate(Assembly.GetExecutingAssembly()).ToString(
+ new CultureInfo("nl-NL")));
+ }
+
+ ///
+ /// Default On
+ /// Based on args get the -i or --index commandline input
+ ///
+ /// args input
+ /// bool, true if --index
+ public static bool GetIndexMode(IReadOnlyList args)
+ {
+ var isIndexMode = true;
- ///
- /// Show in Console the .NET Version (Runtime) and Starsky Version
- /// @see: https://stackoverflow.com/a/58136318
- ///
- private void ShowVersions()
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- var version = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
- _console.WriteLine($".NET Version - {version}");
- _console.WriteLine($"Starsky Version - {_appSettings.AppVersion} " +
- "- build at: " +
- DateAssembly.GetBuildDate(Assembly.GetExecutingAssembly()).ToString(
- new CultureInfo("nl-NL")));
+ if ( ( args[arg].Equals("--index", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-i", StringComparison.CurrentCultureIgnoreCase) )
+ && arg + 1 != args.Count
+ && bool.TryParse(args[arg + 1], out var isIndexMode2) )
+ {
+ isIndexMode = isIndexMode2;
+ }
}
- ///
- /// Default On
- /// Based on args get the -i or --index commandline input
- ///
- /// args input
- /// bool, true if --index
- public static bool GetIndexMode(IReadOnlyList args)
+ return isIndexMode;
+ }
+
+ ///
+ /// Get multiple path from args
+ ///
+ /// args
+ /// list of fullFilePaths
+ /// _appSettings is missing
+ [SuppressMessage("Usage", "S125:Remove this commented out code.",
+ Justification = "Regex as comment")]
+ public List GetPathListFormArgs(IReadOnlyList args)
+ {
+ if ( _appSettings == null )
{
- var isIndexMode = true;
+ throw new FieldAccessException("AppSettings can't be Null at start");
+ }
- for ( var arg = 0; arg < args.Count; arg++ )
- {
- if ( ( args[arg].Equals("--index", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-i", StringComparison.CurrentCultureIgnoreCase) )
- && ( arg + 1 ) != args.Count
- && bool.TryParse(args[arg + 1], out var isIndexMode2) )
- {
- isIndexMode = isIndexMode2;
- }
- }
+ var path = GetUserInputPathFromArg(args);
- return isIndexMode;
+ // To use only with -p or --path > current directory
+ if ( ( args.Contains("-p") || args.Contains(PathCommandLineArgLong) ) &&
+ ( path == string.Empty || path[0] == "-"[0] ) )
+ {
+ path = Directory.GetCurrentDirectory();
}
- ///
- /// Get multiple path from args
- ///
- /// args
- /// list of fullFilePaths
- /// _appSettings is missing
- [SuppressMessage("Usage", "S125:Remove this commented out code.",
- Justification = "Regex as comment")]
- public List GetPathListFormArgs(IReadOnlyList args)
+ // Ignore quotes at beginning: unescaped ^"|"$
+ path = new Regex("^\"|\"$",
+ RegexOptions.None, TimeSpan.FromMilliseconds(100))
+ .Replace(path, string.Empty);
+
+ // split every dot comma but ignore escaped
+ // non escaped: (? !string.IsNullOrWhiteSpace(p)).ToList();
+ }
+
+ ///
+ /// Get the user input from -p or --path
+ ///
+ /// arg list
+ /// path
+ private static string GetUserInputPathFromArg(IReadOnlyList args)
+ {
+ var path = string.Empty;
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- if ( _appSettings == null )
+ if ( ( args[arg].Equals(PathCommandLineArgLong,
+ StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-p", StringComparison.CurrentCultureIgnoreCase) ) &&
+ arg + 1 != args.Count )
{
- throw new FieldAccessException("AppSettings can't be Null at start");
+ path = args[arg + 1];
}
+ }
- var path = GetUserInputPathFromArg(args);
+ return path;
+ }
- // To use only with -p or --path > current directory
- if ( ( args.Contains("-p") || args.Contains(PathCommandLineArgLong) ) &&
- ( path == string.Empty || path[0] == "-"[0] ) )
+ ///
+ /// Get the user input from -p or --password
+ ///
+ /// arg list
+ /// path
+ public static string GetUserInputPassword(IReadOnlyList args)
+ {
+ var path = string.Empty;
+ for ( var arg = 0; arg < args.Count; arg++ )
+ {
+ if ( ( args[arg].Equals("--password", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-p", StringComparison.CurrentCultureIgnoreCase) ) &&
+ arg + 1 != args.Count )
{
- path = Directory.GetCurrentDirectory();
+ path = args[arg + 1];
}
-
- // Ignore quotes at beginning: unescaped ^"|"$
- path = new Regex("^\"|\"$",
- RegexOptions.None, TimeSpan.FromMilliseconds(100))
- .Replace(path, string.Empty);
-
- // split every dot comma but ignore escaped
- // non escaped: (? !string.IsNullOrWhiteSpace(p)).ToList();
}
- private const string PathCommandLineArgLong = "--path";
+ return path;
+ }
- ///
- /// Get the user input from -p or --path
- ///
- /// arg list
- /// path
- private static string GetUserInputPathFromArg(IReadOnlyList args)
+ ///
+ /// Get output mode
+ ///
+ /// arg list
+ /// path
+ public static ConsoleOutputMode GetConsoleOutputMode(IReadOnlyList args)
+ {
+ var outputMode = ConsoleOutputMode.Default;
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- var path = string.Empty;
- for ( var arg = 0; arg < args.Count; arg++ )
+ if ( !args[arg].Equals("--output", StringComparison.CurrentCultureIgnoreCase) ||
+ arg + 1 == args.Count )
{
- if ( ( args[arg].Equals(PathCommandLineArgLong,
- StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-p", StringComparison.CurrentCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count )
- {
- path = args[arg + 1];
- }
+ continue;
}
- return path;
+ var outputModeItem = args[arg + 1];
+ Enum.TryParse(outputModeItem, true, out outputMode);
}
- ///
- /// Get the user input from -p or --password
- ///
- /// arg list
- /// path
- public static string GetUserInputPassword(IReadOnlyList args)
+ return outputMode;
+ }
+
+ ///
+ /// Get the user input from -n or --name
+ ///
+ /// arg list
+ /// name
+ public static string GetName(IReadOnlyList args)
+ {
+ var name = string.Empty;
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- var path = string.Empty;
- for ( var arg = 0; arg < args.Count; arg++ )
+ if ( ( args[arg].Equals("--name", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-n", StringComparison.CurrentCultureIgnoreCase) ) &&
+ arg + 1 != args.Count )
{
- if ( ( args[arg].Equals("--password", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-p", StringComparison.CurrentCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count )
- {
- path = args[arg + 1];
- }
+ name = args[arg + 1];
}
+ }
- return path;
+ return name;
+ }
+
+ ///
+ /// Get path from args
+ ///
+ /// args
+ /// convert to subPath style, default=true
+ /// string path
+ /// appSettings is missing
+ public string GetPathFormArgs(IReadOnlyList args, bool dbStyle = true)
+ {
+ if ( _appSettings == null )
+ {
+ throw new FieldAccessException("use with _appSettings in ctor");
}
- ///
- /// Get output mode
- ///
- /// arg list
- /// path
- public static ConsoleOutputMode GetConsoleOutputMode(IReadOnlyList args)
+ var path = GetUserInputPathFromArg(args);
+
+ // To use only with -p or --path > current directory
+ if ( ( args.Contains("-p") || args.Contains(PathCommandLineArgLong) ) &&
+ ( path == string.Empty || path[0] == "-"[0] ) )
{
- var outputMode = ConsoleOutputMode.Default;
- for ( var arg = 0; arg < args.Count; arg++ )
+ var currentDirectory = Directory.GetCurrentDirectory();
+ if ( currentDirectory != _appSettings.BaseDirectoryProject )
{
- if ( ( !args[arg].Equals("--output", StringComparison.CurrentCultureIgnoreCase) ) ||
- ( arg + 1 ) == args.Count )
+ path = currentDirectory;
+ if ( _appSettings.IsVerbose() )
{
- continue;
+ Console.WriteLine($">> currentDirectory: {currentDirectory}");
}
-
- var outputModeItem = args[arg + 1];
- Enum.TryParse(outputModeItem, true, out outputMode);
}
+ }
- return outputMode;
+ if ( dbStyle )
+ {
+ path = _appSettings.FullPathToDatabaseStyle(path);
}
- ///
- /// Get the user input from -n or --name
- ///
- /// arg list
- /// name
- public static string GetName(IReadOnlyList args)
+ return path;
+ }
+
+ ///
+ /// Get --subpath from args
+ ///
+ /// args
+ /// subPath string
+ public static string GetSubPathFormArgs(IReadOnlyList args)
+ {
+ var subPath = "/";
+
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- var name = string.Empty;
- for ( var arg = 0; arg < args.Count; arg++ )
+ if ( ( args[arg].Equals("--subpath", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-s", StringComparison.CurrentCultureIgnoreCase) ) &&
+ arg + 1 != args.Count )
{
- if ( ( args[arg].Equals("--name", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-n", StringComparison.CurrentCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count )
- {
- name = args[arg + 1];
- }
+ subPath = args[arg + 1];
}
-
- return name;
}
- ///
- /// Get path from args
- ///
- /// args
- /// convert to subPath style, default=true
- /// string path
- /// appSettings is missing
- public string GetPathFormArgs(IReadOnlyList args, bool dbStyle = true)
+ return subPath;
+ }
+
+ ///
+ /// Get subPathRelative, so a structured url based on relative datetime
+ ///
+ /// args[]
+ /// relative subPath
+ /// missing appSettings
+ public int? GetRelativeValue(IReadOnlyList args)
+ {
+ if ( _appSettings == null )
{
- if ( _appSettings == null )
- {
- throw new FieldAccessException("use with _appSettings in ctor");
- }
+ throw new FieldAccessException("use with _appSettings in ctor");
+ }
- var path = GetUserInputPathFromArg(args);
+ var subPathRelative = string.Empty;
- // To use only with -p or --path > current directory
- if ( ( args.Contains("-p") || args.Contains(PathCommandLineArgLong) ) &&
- ( path == string.Empty || path[0] == "-"[0] ) )
+ for ( var arg = 0; arg < args.Count; arg++ )
+ {
+ if ( ( args[arg].Equals("--subpathrelative",
+ StringComparison.InvariantCultureIgnoreCase) ||
+ args[arg].Equals("-g", StringComparison.InvariantCultureIgnoreCase) ) &&
+ arg + 1 != args.Count )
{
- var currentDirectory = Directory.GetCurrentDirectory();
- if ( currentDirectory != _appSettings.BaseDirectoryProject )
- {
- path = currentDirectory;
- if ( _appSettings.IsVerbose() )
- {
- Console.WriteLine($">> currentDirectory: {currentDirectory}");
- }
- }
+ subPathRelative = args[arg + 1];
}
+ }
- if ( dbStyle )
- {
- path = _appSettings.FullPathToDatabaseStyle(path);
- }
+ if ( string.IsNullOrWhiteSpace(subPathRelative) )
+ {
+ return null; // null
+ }
- return path;
+ if ( int.TryParse(subPathRelative, out var subPathInt) && subPathInt >= 1 )
+ {
+ subPathInt *= -1; // always in the past
}
- ///
- /// Get --subpath from args
- ///
- /// args
- /// subPath string
- public static string GetSubPathFormArgs(IReadOnlyList args)
+ // Fallback for dates older than 24-11-1854 to avoid a exception.
+ if ( subPathInt < -60000 )
{
- var subPath = "/";
+ return null;
+ }
- for ( var arg = 0; arg < args.Count; arg++ )
- {
- if ( ( args[arg].Equals("--subpath", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-s", StringComparison.CurrentCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count )
- {
- subPath = args[arg + 1];
- }
- }
+ return subPathInt;
+ }
- return subPath;
+ ///
+ /// Know if --subpath or --path
+ ///
+ /// input[]
+ /// bool --path(true), false --subpath
+ public static bool IsSubPathOrPath(IReadOnlyList args)
+ {
+ // To use only with -p or --path > current directory
+ if ( args.Any(arg =>
+ arg.Equals(PathCommandLineArgLong,
+ StringComparison.CurrentCultureIgnoreCase) ||
+ arg.Equals("-p", StringComparison.CurrentCultureIgnoreCase)) )
+ {
+ return false;
}
- ///
- /// Get subPathRelative, so a structured url based on relative datetime
- ///
- /// args[]
- /// relative subPath
- /// missing appSettings
- public int? GetRelativeValue(IReadOnlyList args)
+ // Detect if an input is a fullPath or a subPath.
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- if ( _appSettings == null )
+ if ( ( args[arg].Equals("--subpath", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-s", StringComparison.CurrentCultureIgnoreCase) ) &&
+ arg + 1 != args.Count )
{
- throw new FieldAccessException("use with _appSettings in ctor");
+ return true;
}
+ }
- var subPathRelative = string.Empty;
+ return true;
+ }
- for ( int arg = 0; arg < args.Count; arg++ )
- {
- if ( ( args[arg].Equals("--subpathrelative",
- StringComparison.InvariantCultureIgnoreCase) ||
- args[arg].Equals("-g", StringComparison.InvariantCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count )
- {
- subPathRelative = args[arg + 1];
- }
- }
+ ///
+ /// Using both options
+ /// -s = if subPath || -p is path
+ ///
+ ///
+ ///
+ public string SubPathOrPathValue(IReadOnlyList args)
+ {
+ return IsSubPathOrPath(args) ? GetSubPathFormArgs(args) : GetPathFormArgs(args);
+ }
- if ( string.IsNullOrWhiteSpace(subPathRelative) )
- {
- return null; // null
- }
+ ///
+ /// --thumbnail bool
+ ///
+ /// args input
+ /// bool
+ public static bool GetThumbnail(IReadOnlyList args)
+ {
+ var isThumbnail = true;
- if ( int.TryParse(subPathRelative, out var subPathInt) && subPathInt >= 1 )
+ for ( var arg = 0; arg < args.Count; arg++ )
+ {
+ if ( ( args[arg].Equals("--thumbnail", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-t", StringComparison.CurrentCultureIgnoreCase) )
+ && arg + 1 != args.Count &&
+ bool.TryParse(args[arg + 1], out var isThumbnail2) )
{
- subPathInt *= -1; // always in the past
+ isThumbnail = isThumbnail2;
}
+ }
- // Fallback for dates older than 24-11-1854 to avoid a exception.
- if ( subPathInt < -60000 )
- {
- return null;
- }
+ return isThumbnail;
+ }
- return subPathInt;
- }
+ ///
+ /// Check for parent/sub items feature
+ ///
+ /// args input
+ /// bool
+ public bool GetOrphanFolderCheck(IReadOnlyList args)
+ {
+ var isOrphanFolderCheck = false;
- ///
- /// Know if --subpath or --path
- ///
- /// input[]
- /// bool --path(true), false --subpath
- public static bool IsSubPathOrPath(IReadOnlyList args)
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- // To use only with -p or --path > current directory
- if ( args.Any(arg =>
- ( arg.Equals(PathCommandLineArgLong,
- StringComparison.CurrentCultureIgnoreCase) ||
- arg.Equals("-p", StringComparison.CurrentCultureIgnoreCase) )) )
+ if ( ( args[arg].Equals("--orphanfolder",
+ StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-o", StringComparison.CurrentCultureIgnoreCase) )
+ && arg + 1 != args.Count &&
+ bool.TryParse(args[arg + 1], out var isOrphanFolderCheck2) )
{
- return false;
+ isOrphanFolderCheck = isOrphanFolderCheck2;
}
-
- // Detect if a input is a fullPath or a subPath.
- for ( int arg = 0; arg < args.Count; arg++ )
- {
- if ( ( args[arg].Equals("--subpath", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-s", StringComparison.CurrentCultureIgnoreCase) ) &&
- ( arg + 1 ) != args.Count )
- {
- return true;
- }
- }
-
- return true;
}
- ///
- /// Using both options
- /// -s = if subPath || -p is path
- ///
- ///
- ///
- public string SubPathOrPathValue(IReadOnlyList args)
+ if ( _appSettings.IsVerbose() )
{
- return IsSubPathOrPath(args) ? GetSubPathFormArgs(args) : GetPathFormArgs(args);
+ Console.WriteLine(">> isOrphanFolderCheck " + isOrphanFolderCheck);
}
- ///
- /// --thumbnail bool
- ///
- /// args input
- /// bool
- public static bool GetThumbnail(IReadOnlyList args)
- {
- var isThumbnail = true;
-
- for ( var arg = 0; arg < args.Count; arg++ )
- {
- if ( ( args[arg].Equals("--thumbnail", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-t", StringComparison.CurrentCultureIgnoreCase) )
- && ( arg + 1 ) != args.Count &&
- bool.TryParse(args[arg + 1], out var isThumbnail2) )
- {
- isThumbnail = isThumbnail2;
- }
- }
+ return isOrphanFolderCheck;
+ }
- return isThumbnail;
- }
+ ///
+ /// Move files
+ ///
+ /// args input
+ /// bool, true=move
+ public static bool GetMove(IReadOnlyList args)
+ {
+ var getMove = false;
- ///
- /// Check for parent/sub items feature
- ///
- /// args input
- /// bool
- public bool GetOrphanFolderCheck(IReadOnlyList args)
+ for ( var arg = 0; arg < args.Count; arg++ )
{
- var isOrphanFolderCheck = false;
-
- for ( var arg = 0; arg < args.Count; arg++ )
+ if ( ( args[arg].Equals("--move", StringComparison.CurrentCultureIgnoreCase)
+ || args[arg].Equals("-m", StringComparison.CurrentCultureIgnoreCase) )
+ && arg + 1 != args.Count &&
+ bool.TryParse(args[arg + 1], out var getMove2) )
{
- if ( ( args[arg].Equals("--orphanfolder",
- StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-o", StringComparison.CurrentCultureIgnoreCase) )
- && ( arg + 1 ) != args.Count &&
- bool.TryParse(args[arg + 1], out var isOrphanFolderCheck2) )
- {
- isOrphanFolderCheck = isOrphanFolderCheck2;
- }
+ getMove = getMove2;
+ continue;
}
- if ( _appSettings.IsVerbose() )
+ if ( args[arg].Equals("--move", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-m", StringComparison.CurrentCultureIgnoreCase) )
{
- Console.WriteLine(">> isOrphanFolderCheck " + isOrphanFolderCheck);
+ getMove = true;
}
-
- return isOrphanFolderCheck;
}
- ///
- /// Move files
- ///
- /// args input
- /// bool, true=move
- public static bool GetMove(IReadOnlyList args)
- {
- var getMove = false;
+ return getMove;
+ }
- for ( var arg = 0; arg < args.Count; arg++ )
+ ///
+ /// Get all --all true
+ ///
+ /// input args
+ /// bool
+ public static bool GetAll(IReadOnlyList args)
+ {
+ // default false
+ var getAll = false;
+
+ for ( var arg = 0; arg < args.Count; arg++ )
+ {
+ if ( args[arg].Equals("--all", StringComparison.CurrentCultureIgnoreCase) ||
+ args[arg].Equals("-a", StringComparison.CurrentCultureIgnoreCase) )
{
- if ( ( args[arg].Equals("--move", StringComparison.CurrentCultureIgnoreCase)
- || args[arg].Equals("-m", StringComparison.CurrentCultureIgnoreCase) )
- && ( arg + 1 ) != args.Count &&
- bool.TryParse(args[arg + 1], out var getMove2) )
- {
- getMove = getMove2;
- continue;
- }
+ getAll = true;
+ }
- if ( ( args[arg].Equals("--move", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-m", StringComparison.CurrentCultureIgnoreCase) ) )
- {
- getMove = true;
- }
+ if ( ( !args[arg].Equals("--all",
+ StringComparison.CurrentCultureIgnoreCase) &&
+ !args[arg].Equals("-a",
+ StringComparison.CurrentCultureIgnoreCase) ) ||
+ arg + 1 == args.Count )
+ {
+ continue;
}
- return getMove;
+ if ( args[arg + 1].Equals("false",
+ StringComparison.CurrentCultureIgnoreCase) )
+ {
+ getAll = false;
+ }
}
- ///
- /// Get all --all true
- ///
- /// input args
- /// bool
- public static bool GetAll(IReadOnlyList args)
- {
- // default false
- var getAll = false;
-
- for ( int arg = 0; arg < args.Count; arg++ )
- {
- if ( ( args[arg].Equals("--all", StringComparison.CurrentCultureIgnoreCase) ||
- args[arg].Equals("-a", StringComparison.CurrentCultureIgnoreCase) ) )
- {
- getAll = true;
- }
+ return getAll;
+ }
- if ( ( !args[arg].Equals("--all",
- StringComparison.CurrentCultureIgnoreCase) &&
- !args[arg].Equals("-a",
- StringComparison.CurrentCultureIgnoreCase) ) ||
- ( arg + 1 ) == args.Count )
- {
- continue;
- }
+ ///
+ /// Recursive scan for folders
+ ///
+ /// input args
+ /// bool
+ public static bool NeedRecursive(IReadOnlyList args)
+ {
+ var needRecursive = false;
- if ( args[arg + 1].Equals("false",
- StringComparison.CurrentCultureIgnoreCase) )
- {
- getAll = false;
- }
+ foreach ( var arg in args )
+ {
+ if ( arg.Equals("--recursive", StringComparison.CurrentCultureIgnoreCase) ||
+ arg.Equals("-r", StringComparison.CurrentCultureIgnoreCase) )
+ {
+ needRecursive = true;
}
-
- return getAll;
}
- ///
- /// Recursive scan for folders
- ///
- /// input args
- /// bool
- public static bool NeedRecursive(IReadOnlyList args)
- {
- bool needRecursive = false;
+ return needRecursive;
+ }
- foreach ( var arg in args )
+ ///
+ /// Need to remove caches
+ ///
+ /// input args
+ /// bool
+ public static bool NeedCleanup(IReadOnlyList args)
+ {
+ // -x --clean
+ var needCacheCleanup = false;
+
+ foreach ( var arg in args )
+ {
+ if ( arg.Equals("--clean", StringComparison.CurrentCultureIgnoreCase) ||
+ arg.Equals("-x", StringComparison.CurrentCultureIgnoreCase) )
{
- if ( ( arg.Equals("--recursive", StringComparison.CurrentCultureIgnoreCase) ||
- arg.Equals("-r", StringComparison.CurrentCultureIgnoreCase) ) )
- {
- needRecursive = true;
- }
+ needCacheCleanup = true;
}
-
- return needRecursive;
}
- ///
- /// Need to remove caches
- ///
- /// input args
- /// bool
- public static bool NeedCleanup(IReadOnlyList args)
- {
- // -x --clean
- bool needCacheCleanup = false;
+ return needCacheCleanup;
+ }
+
+ ///
+ /// Get colorClass value from args
+ ///
+ /// input args
+ /// number, but valid with colorClass
+ public static int GetColorClass(IReadOnlyList args)
+ {
+ // --colorclass
+ var colorClass = -1;
- foreach ( var arg in args )
+ for ( var arg = 0; arg < args.Count; arg++ )
+ {
+ if ( !args[arg].Equals("--colorclass",
+ StringComparison.CurrentCultureIgnoreCase) ||
+ arg + 1 == args.Count )
{
- if ( ( arg.Equals("--clean", StringComparison.CurrentCultureIgnoreCase) ||
- arg.Equals("-x", StringComparison.CurrentCultureIgnoreCase) ) )
- {
- needCacheCleanup = true;
- }
+ continue;
}
- return needCacheCleanup;
+ var colorClassString = args[arg + 1];
+ var color = ColorClassParser.GetColorClass(colorClassString);
+ colorClass = ( int ) color;
}
- ///
- /// Get colorClass value from args
- ///
- /// input args
- /// number, but valid with colorClass
- public static int GetColorClass(IReadOnlyList args)
- {
- // --colorclass
- var colorClass = -1;
+ return colorClass;
+ }
- for ( var arg = 0; arg < args.Count; arg++ )
- {
- if ( !args[arg].Equals("--colorclass",
- StringComparison.CurrentCultureIgnoreCase) ||
- ( arg + 1 ) == args.Count )
- {
- continue;
- }
+ ///
+ /// Get profile value from args
+ ///
+ /// input args
+ /// number, but valid with colorClass
+ public static string GetProfile(IReadOnlyList args)
+ {
+ // --profile
+ var profile = string.Empty;
- var colorClassString = args[arg + 1];
- var color = ColorClassParser.GetColorClass(colorClassString);
- colorClass = ( int ) color;
+ for ( var arg = 0; arg < args.Count; arg++ )
+ {
+ if ( !args[arg].Equals("--profile",
+ StringComparison.CurrentCultureIgnoreCase) ||
+ arg + 1 == args.Count )
+ {
+ continue;
}
- return colorClass;
+ profile = args[arg + 1];
}
+
+ return profile;
}
}
diff --git a/starsky/starsky.foundation.platform/Helpers/ExtensionRolesHelper.cs b/starsky/starsky.foundation.platform/Helpers/ExtensionRolesHelper.cs
index 634c39e231..e641e42412 100644
--- a/starsky/starsky.foundation.platform/Helpers/ExtensionRolesHelper.cs
+++ b/starsky/starsky.foundation.platform/Helpers/ExtensionRolesHelper.cs
@@ -357,7 +357,7 @@ private static bool IsExtensionForce(string? filename, List checkThisLis
// ReSharper disable once ConvertIfStatementToReturnStatement
if ( filename.ToLowerInvariant().EndsWith(".meta.json") &&
- checkThisList.Contains("meta.json") )
+ checkThisList.Contains("meta.json") )
{
return true;
}
@@ -390,6 +390,7 @@ public static string ReplaceExtensionWithXmp(string? filename)
{
continue;
}
+
// Extension must be three letters
// removed: ExtensionForceXmpUseList.Contains(match.Value.Remove(0, 1).ToLowerInvariant()) &&
if ( filename.Length >= match.Index + 4 )
@@ -417,17 +418,14 @@ public static string ReplaceExtensionWithXmp(string? filename)
2000)]
private static partial Regex FileExtensionRegex();
+ [SuppressMessage("ReSharper", "MustUseReturnValue")]
+ [SuppressMessage("Sonar", "S2674: stream.Read return value isn't used")]
private static byte[] ReadBuffer(Stream stream, int size)
{
var buffer = new byte[size];
try
{
- var count = stream.Read(buffer, 0, buffer.Length);
- if ( count != size )
- {
- Console.WriteLine("Size does not match");
- }
-
+ stream.Read(buffer, 0, buffer.Length);
stream.Close();
stream.Flush();
stream.Dispose(); // also flush
@@ -608,7 +606,7 @@ public static ImageFormat GetImageFormat(byte[] bytes)
private static ImageFormat? GetImageFormatMpeg4(byte[] bytes)
{
var fTypMp4 = new byte[] { 102, 116, 121, 112 }; // 00 00 00 [skip this byte]
- // 66 74 79 70 QuickTime Container 3GG, 3GP, 3G2 FLV
+ // 66 74 79 70 QuickTime Container 3GG, 3GP, 3G2 FLV
if ( fTypMp4.SequenceEqual(bytes.Skip(4).Take(fTypMp4.Length)) )
{
@@ -629,13 +627,13 @@ public static ImageFormat GetImageFormat(byte[] bytes)
var gpx = new byte[] { 60, 103, 112 }; // {
it("renders", () => {
@@ -51,21 +51,4 @@ describe("More Menu", () => {
element.unmount();
});
-
- it("turn off using event", (done) => {
- const element = render();
-
- const menuContext = screen.queryAllByTestId("menu-context")[0];
-
- window.addEventListener(MoreMenuEventCloseConst, () => {
- expect(menuContext.className).toBe("menu-context menu-context--hide");
- done();
- });
-
- act(() => {
- window.dispatchEvent(new CustomEvent(MoreMenuEventCloseConst));
- });
-
- element.unmount();
- });
});
diff --git a/starsky/starsky/clientapp/src/components/atoms/more-menu/more-menu.tsx b/starsky/starsky/clientapp/src/components/atoms/more-menu/more-menu.tsx
index bd115587d0..d49509a046 100644
--- a/starsky/starsky/clientapp/src/components/atoms/more-menu/more-menu.tsx
+++ b/starsky/starsky/clientapp/src/components/atoms/more-menu/more-menu.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from "react";
+import React from "react";
import useGlobalSettings from "../../../hooks/use-global-settings";
import localization from "../../../localization/localization.json";
import { Language } from "../../../shared/language";
@@ -9,8 +9,6 @@ type MoreMenuPropTypes = {
setEnableMoreMenu: React.Dispatch;
};
-export const MoreMenuEventCloseConst = "CLOSE_MORE_MENU";
-
const MoreMenu: React.FunctionComponent = ({
children,
enableMoreMenu,
@@ -22,18 +20,6 @@ const MoreMenu: React.FunctionComponent = ({
const offMoreMenu = () => setEnableMoreMenu(false);
- // todo: Should refactor to avoid the usage in upload files
- // don't use MoreMenuEventCloseConst in upload files
- useEffect(() => {
- // Bind the event listener
- window.addEventListener(MoreMenuEventCloseConst, offMoreMenu);
-
- return () => {
- // Unbind the event listener on clean up
- window.removeEventListener(MoreMenuEventCloseConst, offMoreMenu);
- };
- });
-
return (
<>