{"id":15036094,"url":"https://github.com/oscarmarcusson/argsnet","last_synced_at":"2026-04-06T00:04:54.557Z","repository":{"id":209264000,"uuid":"723459699","full_name":"OscarMarcusson/ArgsNET","owner":"OscarMarcusson","description":"A .NET command line argument parser \u0026 printer library","archived":false,"fork":false,"pushed_at":"2023-11-26T10:57:45.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T12:14:54.306Z","etag":null,"topics":["cli","csharp","csharp-library","parser"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/ArgsNET/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OscarMarcusson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-25T18:29:02.000Z","updated_at":"2023-11-26T13:49:12.000Z","dependencies_parsed_at":"2023-11-26T09:23:47.600Z","dependency_job_id":"d87ce764-8d3d-40e7-844b-76fa6b073da1","html_url":"https://github.com/OscarMarcusson/ArgsNET","commit_stats":null,"previous_names":["oscarmarcusson/argsnet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OscarMarcusson%2FArgsNET","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OscarMarcusson%2FArgsNET/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OscarMarcusson%2FArgsNET/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OscarMarcusson%2FArgsNET/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OscarMarcusson","download_url":"https://codeload.github.com/OscarMarcusson/ArgsNET/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243401509,"owners_count":20285058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","csharp","csharp-library","parser"],"created_at":"2024-09-24T20:30:07.624Z","updated_at":"2025-12-30T01:43:53.104Z","avatar_url":"https://github.com/OscarMarcusson.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ArgsNET\n\n A .NET command line argument parser. It can be used without any configuration, as long as you have a class that can receive the data. For example:\n\n```csharp\nvar arguments = ArgsNET.Deserialize.SystemArguments().To\u003cArguments\u003e(out var errors);\n```\n\nThis assumes we have a class along the lines of this:\n\n```csharp\nclass Arguments\n{\n    public bool help;\n    public string[] input;\n    public string output;\n}\n```\n\nThe above would be able to parse any of the following automatically:\n\n| Variable           | CLI arguments     | Accepts value                                |\n| ------------------ | ----------------- | -------------------------------------------- |\n| `Arguments.help`   | `-h` / `--help`   | No                                           |\n| `Arguments.input`  | `-i` / `--input`  | Yes, like `-i index.html index.js index.css` |\n| `Arguments.output` | `-o` / `--output` | Yes, like `-o build/index.html`              |\n\n## Detailed information\n\n### Flags\n\nAll booleans are understood as flags. A flag does not accept a value, and is instead called just with the argument, like `-v` or `--help`. When this happens, the relevant boolean field or property will be set to true.\n\nNote that flags may only be set once, multiple arguments of the same flag, like `-h -h`, will cause a parse error to be returned, marking the second instance as incorrect.\n\n### Options\n\nAll non-booleans are understood as options. These may accept one or multiple values, depending on if they are arrays (any other collection), or if they are a regular value like just a string or int. The regular values may only be set once, just like flags. Arrays and lists, however, may be set as many times as desired. This can be done with any of the following methods:\n\n| Multi-value method | Example                             |\n| ------------------ | ----------------------------------- |\n| Space separated    | `-i value1 value2 value3`           |\n| Comma separated    | `-i=value1,value2,value3`           |\n| Multiple arguments | `-i value1` `-i value2` `-i value3` |\n\n### Argument names\n\nIf nothing else is specified the argument names are resolved by using the field or property name into a long and short version. The long names are resolved first, and will be formatted as this:\n\n| Variable name      | Argument name           |\n| ------------------ | ----------------------- |\n| example            | --example               |\n| FieldExample       | --field-example         |\n| PropertyExample    | --property-example      |\n| nameWith123Numbers | --name-with-123-numbers |\n\nThe short name, meanwhile, is resolved by using the long name above and trimming it to only use the first letter of each section, like this:\n\n| Long name               | Short name |\n| ----------------------- | ---------- |\n| --example               | -e         |\n| --really-verbose-name   | -rvn       |\n| --name-with-123-numbers | -nw1n      |\n\n#### Custom argument names\n\nIt is possible to define custom names, instead of using the automatic name resolver by using the `ArgumentName` attribute:\n\n```csharp\n[ArgumentName(\"o\", \"output\")]\npublic string output;\n\n[ArgumentName(\"r\", \"hot-reload\")]\npublic bool hotReload;\n```\n\nNote that we do not add any hyphens at the start of the name. Those will be added automatically.\n\nIt is also possible to only set the long argument, and have the short one be automatically generated:\n\n```csharp\n[ArgumentName(\"output\")] // Short = \"-o\"\npublic string output;\n\n[ArgumentName(\"hot-reload\")] // Short = \"-hr\"\npublic bool hotReload;\n```\n\n### Deserializer options\n\nThere are three ways to deserialize arguments:\n\n| Method          | Example                                | Description                                 |\n| --------------- | -------------------------------------- | ------------------------------------------- |\n| SystemArguments | `Deserialize.SystemArguments()`        | Uses the arguments given to the application |\n| String          | `Deserialize.String(\"-o example.txt\")` | Uses a raw string                           |\n| Arguments       | `Deserialize.Arguments(someArgs)`      | Uses a string array                         |\n\nIn most cases the regular `SystemArguments` method will suffice, but in some cases you have different handling depending on the first argument, like `npm install` or `git switch`, where the first argument is not a flag. In these cases it's recommended to implement a switch on the first argument, and then use the `Arguments` method with the something like `Deserialize.Arguments(args.Skip(1).ToArray())`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscarmarcusson%2Fargsnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foscarmarcusson%2Fargsnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscarmarcusson%2Fargsnet/lists"}