CI / Build and test (push) Successful in 5m11s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 8m57s
CI / PostgreSQL 16 integration (push) Successful in 3m10s
CI / PostgreSQL 17 integration (push) Successful in 3m30s
CI / Docker image (push) Successful in 49s
Release / Server image (push) Successful in 1m4s
- :latest follows the highest stable release, or the highest pre-release while none is stable (Chronos.Tools release-channels); bad tags are refused before anything is built. - Unraid: CHRONOS_SPACE_PATH and the template's Array view show the array's free space; the write volume (cache) is shown apart; completions check the archive volume (507). - Settings is a gear, docked at the foot of the admin sidebar; About is the last part of Settings on the desktop and the panel. - Import > Folder > Whole folder: one sequence per format (desktop only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
namespace Chronos.Tools;
|
|
|
|
internal interface ICommand
|
|
{
|
|
string Name { get; }
|
|
string Summary { get; }
|
|
Task<int> RunAsync(string[] args);
|
|
}
|
|
|
|
internal sealed class ToolException(string message) : Exception(message);
|
|
|
|
/// <summary>Minimal option parser: <c>--key value</c> (the last one wins, <see cref="GetAll"/> has every one), <c>--flag</c>, positional arguments.</summary>
|
|
internal sealed class Args
|
|
{
|
|
private readonly Dictionary<string, string?> _options = new(StringComparer.OrdinalIgnoreCase);
|
|
private readonly Dictionary<string, List<string>> _values = new(StringComparer.OrdinalIgnoreCase);
|
|
|
|
public Args(string[] args, params string[] flags)
|
|
{
|
|
for (var i = 0; i < args.Length; i++)
|
|
{
|
|
var a = args[i];
|
|
if (a.StartsWith("--", StringComparison.Ordinal))
|
|
{
|
|
var key = a[2..];
|
|
if (flags.Contains(key, StringComparer.OrdinalIgnoreCase) || i + 1 >= args.Length || args[i + 1].StartsWith("--", StringComparison.Ordinal))
|
|
_options[key] = null;
|
|
else
|
|
{
|
|
_options[key] = args[++i];
|
|
if (!_values.TryGetValue(key, out var values)) _values[key] = values = [];
|
|
values.Add(args[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Positional.Add(a);
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<string> Positional { get; } = [];
|
|
|
|
public bool Has(string key) => _options.ContainsKey(key);
|
|
|
|
public string? Get(string key) => _options.TryGetValue(key, out var v) ? v : null;
|
|
|
|
public string Get(string key, string fallback) => Get(key) ?? fallback;
|
|
|
|
/// <summary>Every value of an option given more than once (<c>--key a --key b</c>), in order.</summary>
|
|
public IReadOnlyList<string> GetAll(string key) => _values.TryGetValue(key, out var values) ? values : [];
|
|
|
|
public static string RepoRoot()
|
|
{
|
|
var dir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
|
while (dir is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(dir.FullName, "Chronos.slnx"))) return dir.FullName;
|
|
dir = dir.Parent;
|
|
}
|
|
dir = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (dir is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(dir.FullName, "Chronos.slnx"))) return dir.FullName;
|
|
dir = dir.Parent;
|
|
}
|
|
throw new ToolException("Repository root (Chronos.slnx) not found.");
|
|
}
|
|
}
|