{"id":28523115,"url":"https://github.com/ucswift/consolas2","last_synced_at":"2025-07-06T03:30:34.027Z","repository":{"id":139582873,"uuid":"212928348","full_name":"ucswift/Consolas2","owner":"ucswift","description":"Consolas2 - a console application framework for the .Net Framework and DotNetCore","archived":false,"fork":false,"pushed_at":"2019-10-08T23:28:48.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T10:07:16.558Z","etag":null,"topics":["c-sharp","cli","console","console-framework","dotnet-core","dotnet-framework","dotnet-standard"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ucswift.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,"zenodo":null}},"created_at":"2019-10-05T01:35:56.000Z","updated_at":"2019-11-21T10:51:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a404b90-8cd8-4867-aab3-2c440c623095","html_url":"https://github.com/ucswift/Consolas2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ucswift/Consolas2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucswift%2FConsolas2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucswift%2FConsolas2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucswift%2FConsolas2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucswift%2FConsolas2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ucswift","download_url":"https://codeload.github.com/ucswift/Consolas2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucswift%2FConsolas2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263842954,"owners_count":23518691,"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":["c-sharp","cli","console","console-framework","dotnet-core","dotnet-framework","dotnet-standard"],"created_at":"2025-06-09T10:07:15.242Z","updated_at":"2025-07-06T03:30:34.019Z","avatar_url":"https://github.com/ucswift.png","language":"C#","readme":"Consolas2\n===========================\n\nConsolas2 is a dotnetcore update to the Consolas console application framework developed by [Rickard Nilsson](https://github.com/rickardn). Consolas2 simplifies the creation of everything from simple throw away apps to bigger, more complex tools with lots of arguments.\n\n*********\n\n[![Build status](https://ci.appveyor.com/api/projects/status/github/ucswift/consolas2?svg=true)](https://ci.appveyor.com/api/projects/status/github/ucswift/consolas2)\n\u003ca href=\"https://github.com/ucswift/Consolas2/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/ucswift/consolas2.svg\" alt=\"License\" /\u003e\u003c/a\u003e\n\n# Deltas to the original Consolas\n- No RazorEngine view engine support\n- Nustache dependency replaced with Stubble\n- Assembly migrated to .NetStandard 2.0, unit tests are DotNetCore 3.0\n\nGoals of this update were to use core Consolas functionality in .Net Framework and DotNetCore based applications. Utilizing .NetStandard 2.0 the assembly will work cross framework. A factor in migrating to .Net Standard you will need to manually create the \"Args\", \"Commands\" and \"Views\" folders in your console application.\n\n\n# Features\n- Convention over configuration\n- Small fingerprint\n- Testable\n- Mustache view engine\n\n## How to get it\n\nSimply create a new Console Application and install the Nuget package [Consolas2](https://www.nuget.org/packages/Consolas2/) or run the following command in the Package Manager Console\n\n\u003cpre\u003e\nPM\u003e Install-Package Consolas2\n\u003c/pre\u003e\n\nAfter installation you will need to create 3 Directories in the root of your Console application, \"Args\", \"Commands\" and \"Views\". Your structure will look like the one below.\n\n\u003cpre\u003e\nConsole App\n   |-\u003e Args\n       |-\u003e [MyParam]Args.cs\n   |-\u003e Commands\n       |-\u003e [MyParam]Command.cs\n   |-\u003e Views\n       |-\u003e [MyParam].template\n\u003c/pre\u003e\n\nAt a minimum you need a file in the Args directory (i.e. HelpArgs.cs) and in the Commands directory (i.e. HelpCommand.cs) for all the commands you want your cli application to accept. \n\n## Simple example\n\n```csharp\nclass Program : ConsoleApp\u003cProgram\u003e\n{\n    static void Main(string[] args)\n    {\n        Match(args);\n    }\n}\n\npublic class HelpArgs\n{\n    public bool Help { get; set; }\n}\n\npublic class HelpCommand : Command\n{\n    public string Execute(HelpArgs args)\n    {\n        return \"Using: Program.exe ...\";\n    }\n}\n```\n\n### Running the above program from a console\n\n\u003cpre\u003e\nC\u003e program.exe -Help\nUsing: Program.exe ...\n\u003c/pre\u003e\n\n## Unit testing\n### Unit tests\nUnit testing Consolas Commands is easy:\n```csharp\n[TestFixture]\npublic class GrepCommandTests\n{\n    [Test]\n    public void Execute_ValidArgument_ReturnsGrepedText()\n    {\n        var command = new GrepCommand();\n\n        var result = command.Execute(new GrepArgs\n        {\n            FileName = \"doc.txt\",\n            Regex = \"foo\"\n        });\n\n        StringAssert.Contains(\"foo bar baz\", result);\n    }\n}\n```\n\n### End to end tests\nThe following is a [sample](https://github.com/rickardn/Consolas/blob/master/Source/UnitTests/Samples/Samples.Grep.Tests/EndToEndTests.cs) testing a console application from end to end:\n\n```csharp\n[TestFixture]\npublic class EndToEndTests\n{\n    private StringBuilder _consoleOut;\n    private TextWriter _outWriter;\n\n    [SetUp]\n    public void Setup()\n    {\n        _outWriter = Console.Out;\n        _consoleOut = new StringBuilder();\n        Console.SetOut(new StringWriter(_consoleOut));\n    }\n\n    [TearDown]\n    public void TearDown()\n    {\n        Console.SetOut(_outWriter);\n    }\n\n    [Test]\n    public void Version()\n    {\n        Program.Main(new []{ \"-version\"});\n        StringAssert.Contains(\"2.4.2\", _consoleOut.ToString());\n    }\n}\n```\n\n\n## Advanced examples\n- [Classic UNIX grep sample](https://github.com/rickardn/Consolas/tree/master/Source/Samples/Samples.Grep)\n- [Ping a network address](https://github.com/rickardn/Consolas/tree/master/Source/Samples/Samples.Ping)\n\n## Author's\n* Original Consolas author [Rickard Nilsson](http://www.rickardnilsson.net)\n* Shawn Jackson (Twitter: @DesignLimbo Blog: http://designlimbo.com)\n\n## License\n\n[BSD 2-Clause License](https://github.com/rickardn/Consolas/blob/master/LICENCE.md)\n\n\n## Acknowledgments\n\nConsolas2 makes use of the following OSS projects:\n\n- SimpleInjector released under the MIT license: https://simpleinjector.codeplex.com/license\n- Stubble released under the MIT license: https://github.com/StubbleOrg/Stubble/blob/master/licence.md\n- NUnit released under the NUnit license: http://nunit.org/nuget/license.html\n- Fluent Assertions released under the Apache 2.0 license: https://github.com/fluentassertions/fluentassertions/blob/master/LICENSE\n- NSubstitute released under the BSD license: https://raw.githubusercontent.com/nsubstitute/NSubstitute/master/LICENSE.txt\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucswift%2Fconsolas2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucswift%2Fconsolas2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucswift%2Fconsolas2/lists"}