{"id":22065545,"url":"https://github.com/karenpayneoregon/command-line-samples","last_synced_at":"2026-02-18T07:31:57.637Z","repository":{"id":110840389,"uuid":"443603298","full_name":"karenpayneoregon/command-line-samples","owner":"karenpayneoregon","description":"Code sample for working with command line arguments for console and dotnet tool projects","archived":false,"fork":false,"pushed_at":"2025-01-15T12:25:20.000Z","size":6000,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T13:26:31.140Z","etag":null,"topics":["console-application","csharp-core","dotnet-tools"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karenpayneoregon.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-01-01T18:52:17.000Z","updated_at":"2025-01-15T12:25:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"f6feed74-1979-4245-84c8-117e389d7885","html_url":"https://github.com/karenpayneoregon/command-line-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/karenpayneoregon/command-line-samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fcommand-line-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fcommand-line-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fcommand-line-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fcommand-line-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karenpayneoregon","download_url":"https://codeload.github.com/karenpayneoregon/command-line-samples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Fcommand-line-samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29572400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T06:19:27.422Z","status":"ssl_error","status_checked_at":"2026-02-18T06:18:44.348Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["console-application","csharp-core","dotnet-tools"],"created_at":"2024-11-30T19:19:27.562Z","updated_at":"2026-02-18T07:31:57.621Z","avatar_url":"https://github.com/karenpayneoregon.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C# Parsing command line arguments\n\nLearn how to work with arguments passed to an application using [CommandLineParser](https://github.com/commandlineparser/commandline) via NuGet [package](https://www.nuget.org/packages/CommandLineParser/2.8.0).\n\nThere are plenty of code samples on the web that show how to use this library but none have complete working code while this repository has several code samples to make it easy to learn.\n\nIncluded in this repository are console, dotnet tool and windows form projects using CommandLineParser library.\n\nNote myage is a simply examples which accepts two dates and calcutates a person's age using the same code pattern used in the plain old console code samples.\n\n`-f` or `--from` for earlier date and `-t` or `--to` for later date.\n\n![img](assets/tool.png)\n\n## Points of interest\n\n- Completely OOP centric code, not procedural, clean and easy to read\n- How to create custom header, see `figure 1`\n- How to setup custom help, see `figure 1`\n- `Debug.WriteLine` is used in many places in code, this allows the person running code to easily see what is happening to learn from. For usage in a real application use `Console.WriteLine`.\n- Use PowerShell to run examples e.g. `dotnet run` followed by arguments.\n\n![img](assets/Figure1.png)\n\n## Description of library\n\nThe Command Line Parser Library offers CLR applications a clean and concise API for manipulating command line arguments and related tasks, such as defining switches, options and verb commands. It allows you to display a help screen with a high degree of customization and a simple way to report syntax errors to the end user.\n\n# Documentation\n\n- [Wiki](https://github.com/commandlineparser/commandline/wiki)\n- [At a glance](https://github.com/commandlineparser/commandline#at-a-glance)\n\n\n# Included projects\n\nTo demonstrate various features there are two projects, `PromptForUserNamePassword` and `ArgumentWithMultipleValues` and one functional project, `MarkOfWeb`.\n\n## How to learn\n\nThe best way for novice developers to learn how to work with this library is to set a breakpoint at the first line of code, step through unit the end of the program.\n\nEach project has application arguments set to easily try out. Before running, check what the arguments are as you may need to change them. For instance, in the MarkOfTheWeb project we have a folder that surely does not exists on your computer so change it.\n\n![img](assets/figure2.png)\n\nIn some cases arguments are short version, others long version and some mixed.\n\nFor instance, `-u` (short) or `--username` (long)\n\n```csharp\nusing CommandLine;\n\nnamespace PromptForUserNamePassword.Classes\n{\n    public sealed class CommandLineOptions\n    {\n        [Option('u', \"username\", Required = true, HelpText = \"Your username\")]\n        public string Username { get; set; }\n    }\n}\n```\n\nFor experienced developers, examine the code, run and adapt to your applications.\n\n# Dotnet global tools\n\nIf working with  .NET Core 2.1 SDK and later versions you can use the command line parser to parse command line arguments also. If unfamilar with these tools see [the following](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools-how-to-create).\n\nExample using [CommandLineParser](https://github.com/commandlineparser/commandline) is [dotnet-cleanup](https://github.com/sebnilsson/DotnetCleanup) and [quickup](https://github.com/Sergio0694/quickup).\n\n## List tools\n\ndotnet tool list -g\n\n# Copy rights\n\nThere are several places in code that have a copy right, these are to show how to display a copy right and are to be considered just that. There are no copyrights on code provided.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Fcommand-line-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarenpayneoregon%2Fcommand-line-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Fcommand-line-samples/lists"}