2023-06-26 11:58:41 +00:00
|
|
|
|
namespace ArgsUniform
|
|
|
|
|
{
|
|
|
|
|
public class ExampleUser
|
|
|
|
|
{
|
|
|
|
|
public class Args
|
|
|
|
|
{
|
|
|
|
|
[Uniform("aaa", "a", "AAA", false, "Sets the AAA!")]
|
|
|
|
|
public string Aaa { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[Uniform("bbb", "b", "BBB", true, "Sets that BBB")]
|
|
|
|
|
public string Bbb { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DefaultsProvider
|
|
|
|
|
{
|
|
|
|
|
public string Aaa { get { return "non-static operation"; } }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Example()
|
|
|
|
|
{
|
|
|
|
|
// env var: "AAA=BBB"
|
|
|
|
|
var args = "--ccc=ddd";
|
|
|
|
|
|
2023-06-30 07:09:59 +00:00
|
|
|
|
var uniform = new ArgsUniform<Args>(PrintHelp, new DefaultsProvider(), args);
|
2023-06-26 11:58:41 +00:00
|
|
|
|
|
|
|
|
|
var aaa = uniform.Parse();
|
|
|
|
|
}
|
2023-06-30 07:09:59 +00:00
|
|
|
|
|
|
|
|
|
private static void PrintHelp()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Help text!");
|
|
|
|
|
}
|
2023-06-26 11:58:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|