Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Unity-Technologies/UnityOptions
https://github.com/Unity-Technologies/UnityOptions
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/Unity-Technologies/UnityOptions
- Owner: Unity-Technologies
- Created: 2017-06-16T16:19:14.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-02-15T19:38:29.000Z (4 months ago)
- Last Synced: 2024-02-15T20:32:29.721Z (4 months ago)
- Language: C#
- Size: 4.52 MB
- Stars: 138
- Watchers: 657
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Lists
- awesome-stars - UnityOptions - Technologies | 133 | (C#)
README
# UnityOptions
A library to help make command line argument parsing easy
```
public static void Main(string[] args)
{
if (!Options.InitAndSetup(args))
return;...
Do stuff
...
}[ProgramOptions]
public static class Options
{
[HelpDetails("This is the first option")]
public static string SomeValue;[HelpDetails("This is the first option")]
public static string AnotherValue;public static void SetToDefaults()
{
}public static string NameFor(string fieldName)
{
return OptionsParser.OptionNameFor(typeof(Options), fieldName);
}public static bool InitAndSetup(string[] args)
{
SetToDefaults();if (OptionsParser.HelpRequested(args))
{
OptionsParser.DisplayHelp(typeof(Program).Assembly, false);
return false;
}var unknownArgs = OptionsParser.Prepare(args, typeof(Program).Assembly, false).ToList();
if (unknownArgs.Count > 0)
{
Console.WriteLine("Unknown arguments : ");
foreach (var remain in unknownArgs)
{
Console.WriteLine("\t {0}", remain);
}return false;
}ValidateArguments();
return true;
}
}
```