{"id":16203708,"url":"https://github.com/bbepis/nargs","last_synced_at":"2025-04-07T19:26:27.778Z","repository":{"id":116505552,"uuid":"391291315","full_name":"bbepis/NArgs","owner":"bbepis","description":"Simple single-file argument parser for C#","archived":false,"fork":false,"pushed_at":"2021-07-31T12:50:40.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T20:52:55.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bbepis.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":"2021-07-31T08:00:30.000Z","updated_at":"2022-05-11T15:01:37.000Z","dependencies_parsed_at":"2023-04-19T23:28:37.639Z","dependency_job_id":null,"html_url":"https://github.com/bbepis/NArgs","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"7a9bf48ea06683941955fea8a3450a7b823cdadd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbepis%2FNArgs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbepis%2FNArgs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbepis%2FNArgs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbepis%2FNArgs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbepis","download_url":"https://codeload.github.com/bbepis/NArgs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247714843,"owners_count":20983953,"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":[],"created_at":"2024-10-10T09:54:51.859Z","updated_at":"2025-04-07T19:26:27.740Z","avatar_url":"https://github.com/bbepis.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NArgs\nSimple single-file argument parser for C#\n\nJust copy NArgs.cs into your project and you're ready to go.\n\n### Usage\n\n```cs\nusing NArgs;\n\nclass MyArguments : IArgumentCollection\n{\n    public IList\u003cstring\u003e Values { get; set; }\n\n    [CommandDefinition(\"r\", \"required\", Description = \"This is required\", Required = true)]\n    public string RequiredArg { get; set; }\n\n    [CommandDefinition(\"collection\", Description = \"A collection of strings\", Required = true)]\n    public IList\u003cstring\u003e StringCollection { get; set; }\n\n    [CommandDefinition(\"h\", \"help\", Description = \"Prints help text\")]\n    public bool Help { get; set; }\n}\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        MyArguments arguments = Arguments.Parse\u003cMyArguments\u003e(args);\n\n        if (arguments.Values.Count == 0 || arguments.Help)\n        {\n            Console.WriteLine(Arguments.PrintLongHelp\u003cMyArguments\u003e(\n                \"MyApp v1.0.0, by me\",\n                \"Usage: MyApp [options] \u003cvalues\u003e\"));\n            return;\n        }\n        \n        ...\n    }\n}\n```\n\n`PrintLongHelp` in the example writes this to console:\n\n```\nMyApp v1.0.0, by me\nUsage: MyApp [options] \u003cvalues\u003e\n\n\n  -h, --help                                 Prints help text\n\n  -r \u003cvalue\u003e, --required \u003cvalue\u003e             This is required\n\n  --collection \u003cvalue\u003e                       A collection of strings\n```\n\nAn argument class must inherit from `IArgumentCollection`. There are four property types supported:\n\n- `bool`: Is `true` if the argument was provided, `false` if not. `Required` is not applicable to this argument type.\n- `string`: Is set to the value of `--stringArg \u003cvalue\u003e`, otherwise `null` if not provided.\n- `IList\u003cstring\u003e`: Similar to the above, however collects multiple values into a single list. Does *not* split the value on comma or anything else, instead appends multiple usages (i.e. `--listArg value1 --listArg value2`) into a single list. List is empty if not provided.\n- Any enum. Will parse a case-insensitive string value into an enum. Will throw if unable to parse the enum correctly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbepis%2Fnargs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbepis%2Fnargs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbepis%2Fnargs/lists"}