Solution layout, build rules with zero-package guard, in-house test framework, localization runtime, brand mark rasteriser with ICO/PNG generation, Core contracts (imaging, video, domain model, TIFF reader), Titano.Tools (make-icon, i18n, xaml-lint, package-guard) and docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
namespace Titano.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>, <c>--flag</c>, positional arguments.</summary>
|
|
internal sealed class Args
|
|
{
|
|
private readonly Dictionary<string, string?> _options = 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];
|
|
}
|
|
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;
|
|
|
|
public static string RepoRoot()
|
|
{
|
|
var dir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
|
while (dir is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(dir.FullName, "Titano.slnx"))) return dir.FullName;
|
|
dir = dir.Parent;
|
|
}
|
|
dir = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (dir is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(dir.FullName, "Titano.slnx"))) return dir.FullName;
|
|
dir = dir.Parent;
|
|
}
|
|
throw new ToolException("Repository root (Titano.slnx) not found.");
|
|
}
|
|
}
|