{"id":20641852,"url":"https://github.com/franck-gaspoz/commandline.netcore","last_synced_at":"2025-04-16T01:41:44.705Z","repository":{"id":64942919,"uuid":"579714456","full_name":"franck-gaspoz/CommandLine.NetCore","owner":"franck-gaspoz","description":"Provides support to handle command line arguments (parse, validate, command pattern) for .Net Core console applications with ANSI VT support (cursor,colors,screen size) for multi-plateform (windows, linux, osx, arm) console applications using C# and .NET Core 6","archived":false,"fork":false,"pushed_at":"2024-04-11T13:41:01.000Z","size":14649,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T03:32:17.579Z","etag":null,"topics":["ansi-colors","argument-parser","arguments","cli-app","command","command-line","command-line-tool","console","console-application","library","line","netcore","pattern","vt100"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/franck-gaspoz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2022-12-18T16:44:54.000Z","updated_at":"2025-02-20T13:14:03.000Z","dependencies_parsed_at":"2024-02-14T12:38:23.634Z","dependency_job_id":null,"html_url":"https://github.com/franck-gaspoz/CommandLine.NetCore","commit_stats":{"total_commits":164,"total_committers":1,"mean_commits":164.0,"dds":0.0,"last_synced_commit":"4bb0853dee2730e0c003942e03055fc047b62980"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FCommandLine.NetCore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FCommandLine.NetCore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FCommandLine.NetCore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franck-gaspoz%2FCommandLine.NetCore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franck-gaspoz","download_url":"https://codeload.github.com/franck-gaspoz/CommandLine.NetCore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249182803,"owners_count":21226123,"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":["ansi-colors","argument-parser","arguments","cli-app","command","command-line","command-line-tool","console","console-application","library","line","netcore","pattern","vt100"],"created_at":"2024-11-16T16:06:59.569Z","updated_at":"2025-04-16T01:41:44.685Z","avatar_url":"https://github.com/franck-gaspoz.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿___\n\n# ![CommandLine.NetCore](https://raw.githubusercontent.com/franck-gaspoz/CommandLine.NetCore/main/CommandLine.NetCore/assets/ascii-icon.png \"CommandLine.NetCore\") CommandLine.NetCore\n\n___\n\n**CommandLine.NetCore library** provides support to handle command line arguments (parse, validate, command pattern) for .Net Core console applications with ANSI VT support (cursor,colors,screen size) for multi-plateform (windows, linux, osx, arm) console applications using C# and .NET Core 6\n\n[![licence mit](https://img.shields.io/badge/licence-MIT-blue.svg)](license.md) This project is licensed under the terms of the MIT license: [LICENSE.md](LICENSE.md)  \n![last commit](https://img.shields.io/github/last-commit/franck-gaspoz/CommandLine.NetCore?style=plastic)\n![version](https://img.shields.io/github/v/tag/franck-gaspoz/CommandLine.NetCore?style=plastic)\n___\n\n# Index\n\n- [Features](#features)\n- [How to](#howto)\n    - [1. Running the command line](#1-running-the-command-line)\n    - [2. Testing the integrated **help** command](#2-testing-the-integrated-help-command)\n    - [3. Configuring the library and a console application built with it](#3-configuring-the-library-and-a-console-application-built-with-it)\n    - [4. Implementing a command](#4-implementing-a-command)\n\n        - [4.1 Implementing a command with a \u003cb\u003eclass\u003c/b\u003e](#4-1-implementing-a-command-with-a-class)\n            - [Arguments to concrete types mapping of Do(LambdaExpression expression) expression parameters](#arguments-to-concrete-types-mapping-of-dolambdaexpression-expression-expression-parameters)\n            - [Exemple of the command `help` defined in `CommandLine.NetCore.Commands.CmdLine`](#exemple-of-the-command-help-defined-in-commandlinenetcorecommandscmdline)\n            - [Exemple of the command `get-info` defined in `CommandLine.NetCore.Example.Commands.GetInfo`](#exemple-of-the-command-get-info-defined-in-commandlinenetcoreexamplecommandsgetinfo)\n        - [4.2 Implementing a \u003cb\u003eclassless\u003c/b\u003e command with a lambda expression](#4-2-implementing-a-classless-command-with-a-lambda-expression) \n    \n    - [5. Setup an unique command console app (without command argument)](#5-setup-an-unique-command-console-app-without-command-argument)\n    - [6. Command classes attributes](#6-command-classes-attributes)\n    - [7. Debug and troobleshoot](#7-debug-and-troobleshoot)\n\n- [Versions history](#versions-history)\n\n# Features\n\nThe library provides functionalities needed to build console applications running in a terminal (WSL/WSL2, cmd.exe, ConEmu, bash, ...) with text interface. That includes:\n\n- parsing command line arguments\n\n- command pattern helps implementing commands binded to methods from command line in a simple and regular way\n\n- multi-language commands help configuration files\n\n- automatic **help** command\n\n- can compile a .exe for a a single command command, showing only the help for a specific command, or for several commands, showing a help for all commands as a shell would do\n\n- compatible with [**AnsiVtConsole.NetCore**](https://github.com/franck-gaspoz/AnsiVtConsole.NetCore) :\n\n    - **a text printer engine** that supports **print directives** (markup) allowing to manage console functionalities from text itself, as html would do but with a simplest syntax (that can be configured). That makes possible colored outputs, cursor control, text scrolling and also dynamic C# execution (scripting), based on **System.Console** and **ANSI VT100 / VT52 (VT100 type Fp or 3Fp, Fs, CSI, SGR)** \n\n    - A Ansi Parser that can identify/remove escape sequences in a text\n\n    - The console output can be controlled by:\n        - tokens in a string (print directives)\n        - as string shortcuts (dynamic ansi vt strings)\n        - throught API methods\n\n# Howto\n\n## 1. Running the command line\n\ndownload the nuget from command line or add it from Visual Studio\n\n``` dos\ndotnet add package CommandLine.NetCore\n```\n\n\u003e **Notice**\n\u003e\n\u003e When installing the package, the following files are copied into your project:\n\u003e - Config/appSettings.core.json\n\u003e\n\u003e the file **Config/appSettings.core.json** is mandatory since it contains the CommandLine.NetCore parser root configuration\n\n\nlink to the library in your console application main class (example: Program.cs):\n\n``` csharp\nusing CommandLine.NetCore.Services.CmdLine;\n```\n\nfrom your **main** method of your app or using **top level statements**, transfer control to the library **CommandLine.NetCore** :\n\n`Program.cs`\n\n```csharp\nnamespace MyConsoleApp;\n\n/// \u003csummary\u003e\n/// command line input\n/// \u003cpara\u003ecommandName ( option (optionValue)* | parameter )* globalOption*\u003c/para\u003e\n/// \u003c/summary\u003e\n/// \u003cparam name=\"args\"\u003earguments\u003c/param\u003e\n/// \u003creturns\u003estatus code\u003c/returns\u003e\npublic static int Main(string[] args)\n    =\u003e new CommandLineInterfaceBuilder()\n        .Build(args)\n        .Run();\n```\n\nor using a top level statement:\n\n```csharp\nnew CommandLineInterfaceBuilder()\n    .Build(args)\n    .Run();\n```\n\nThat leads to the loading of any command line components like global arguments, commands and help settings\nfrom both the library core and your own console app and parsing of the declared syntaxes and eventualy execution of the method corresponding to the matching syntax.\n\n## 2. Testing the integrated **help** command:\n\nAny console application built with the library **ComandLine.NetCore** implements by \ndefault a command named **`help`** that dump any available help about commands that are \nimplemented in the software that uses the library and in the library itself. \n\nAs an example, you can build the example application console, provided in the project `CommandLine.NetCore.Example`, \nJust execute in your favorite shell this command (available in the folder `bin/Release/net6.0`):\n\n``` dos\n./CommandLine.NetCore.Example.exe help\n```\n\nTo get the help for a particular command, the syntax is `help {commandName}`. In this example you\nget help about the command help:\n\n``` dos\n./CommandLine.NetCore.Example.exe help help\n```\n\n## 3. Configuring the library and a console application built with it\n\nThe library settings provides the description of the application and of the commands, and also the translation of texts.\nYou should override these settings according to your needs.\n\nEvery settings are pushed throught `IHostBuilder.ConfigureAppConfiguration`. \nSettings are looked up by this way, in the specified order:\n\nprovided by the library CommandLine.NetCore:\n\n- `appSettings.core.json` : this file contains the settings needed by the core functionalities\nof the library: decription of the library, texts and description of the integrated command, in\nthe default language (en-us)\n\n- `appSettings.core.{culture}.json` : same as above, any of these files provides translations for the\nculture specified by the tag `{culture}` according to available cultures specified in `Microsoft.`.\nThe settings file that matches the current platform culture is loaded if it exists.\n\nprovided by your application;\n\n- `appSettings.json` : dscription of the commands provided by your application, the texts, and any\nsettings in the default language (en-us)\n\n- `appSettings.{culture}.json` : same as above for the translations of the culture specified by the tag\n`{culture}`\n\nThe settings must conform with the following conventions:\n\n**Informations about application**\n\n``` json\n\"App\": {\n    \"Title\": \"CommandLine.NetCore\",\n    \"ReleaseDate\": \"10/12/2022\"\n  }\n```\n\n**Texts**\n\n``` json\n\"Texts\": {\n    \"{TextId}\": \"Text\"\n  }\n```\n\n**Description of the commands**\n\n``` json\n\"Commands\": {\n    \"{CommandName}\": {\n        \"Description\": \"short description of the command\",\n        \"Syntax\": {\n            \"{Syntax 1}\" : \"Description of the functionality provided by the syntax 1\",\n            ...\n            \"{Syntax n}\" : \"Description of the functionality provided by the syntax n\",\n        },\n        \"Options\": {\n            \"{Option 1}\" : \"Description of the command option 1\",\n            ...\n            \"{Option n}\" : \"Description of the command option n\",\n        }\n    }\n  }\n```\n\nexample of the command **`help`** :\n\n``` json\n\"Commands\": {\n    \"help\": {\n      \"Description\": \"output a of list commands and global arguments or output help about a command\",\n      \"Syntax\": {\n        \"\": \"list all commands\",\n        \"commandName\": \"help about the command with name commandName\"\n      },\n      \"Options\": {\n        \"-v\": \"enable verbose: add details to normal output\",\n        \"--info\" : \"output additional informations about the command line context\"\n      }\n    }\n  },\n```\n\nThese settings are describing the following syntaxes for the command `help`:\n\n``` dos\n; help for a command\nhelp {commandName} [-v] [--info]\n; global help (all commands)\nhelp [-v] [--info]\n```\n\nCommand options are optionals and are available for any syntax of the command (here -v and --info). They can appears from\nthe position they are declared in the command syntax\n\n**Description of the global arguments**\n\n``` json\n\"GlobalOptions\": {\n    \"{ArgumentName}\": {\n        \"{Syntax}\" : \"Description of the functionality provided by the argument syntax\"\n    }\n  }\n```\n\nGlobal arguments are optional and availables for any command. They must appear from the end of the command arguments\n\nexample of the global argument **`s`** :\n\n``` json\n\"GlobalOptions\": {\n    \"s\": {\n        \"-s\" : \"turn off any output (silent mode)\"\n    }\n  }\n```\n\nby convention (POSIX), single letter arguments are prefixed by `-`, whereas arguments with\nseveral letters are prefixed by `--`\n\n## 4. Implementing a command\n\n### 4.1. Implementing a command with a class\n\nA command specification and implementation is defined in a class that inherits from `CommandLine.NetCore.Services.CmdLine.Commands.Command`.\n\n* the name of the command is `kebab case` from the name of the class (in this case **GetInfo** declares the **get-info** command)\n* the command class msut have a constructor with parameter `Dependencies`. These classes are instantiated by the **dependency injector**,\nthus any registered dependency can be added as a constructor parameter\n* the command class must implements the method:\n    ```csharp\n    CommandResult Execute(ArgSet args)\n    ```\n* the method `Execute` declares the syntaxes of the command and the related implementations\n* the method **`For`** declares a command syntax:\n    ```csharp\n    For(params Arg[] syntax)\n    ```\n- the list of arguments are specifing the command syntax\n    - an `Arg` is either an `option` or a `parameter`. Their grammar is defined as this:\n        - `Option ::= [-|--]{optionName}[value0..valuen]`\n            - options can be expected or optionnal\n            - options can have from 0 to n values\n            - can have from 0 to n values of a type `T`, where T can be any scalar type, a collection of scalar types (with `,` as separator) or an Enum            \n            - an option can be defined with values, values are always expected\n            - `Opt(\"x\")` builds the option `x` with no expected value: `-x`\n            - by convention (posix), if the length of the name of the option is greater than 1, the prefix becomes: `--`. For instance, `Opt(\"xy\")` defines the syntax: `--xy`\n            - `Opt(\"x\",true)` builds the option `x` wich is optional in the syntax\n            - `Opt\u003cT\u003e(\"value\")` builds the option `value` having one expected value that must be convertible to type `T`. For instance, `Opt\u003cint\u003e(\"value\")` defines an option that expect an int, like in syntax: `--value 123`\n            - **Flag** is a construct of an **Opt** without value\n\n        - `Parameter ::= parameterValue?`\n            - parameters have exactly one value\n            - parameters are always expected\n            - have a value of a type `T`, where T can be any scalar type, a collection of scalar types (with `,` as separator) or an Enum            \n            - if a parameter if defined with a value, it is an expected word in the syntax\n            - if a parameter is defined without a value, a value is expected in the syntax\n            - `Param()` builds a parameter that expect a value of type `string` like in syntax: `iamastring`\n            - `Param\u003cT\u003e()` builds a parameter that expect a value that must be convertible to type `T`. For instance, `Param\u003cint\u003e()` builds a parameter that expect a value of type `int`, like in syntax: `123`\n            - `Param(\"color\")` builds a parameter that is expected and being the syntax: `color`\n            \n* the method **`Do`** chained to a **For** indicates the method that must be executed if the syntax match the command line args:\n    \n    - the most common way to define the operation method si the lambda expression, since it allows to use a standard method with concrete typed parameters (not Opt,Param,.. but the values types inside it) :\n\n    ```csharp\n    // takes a method in a lambda unary call expression: () =\u003e methodName, takes a called method with no parameter, takes a called method with a default command result (code ok, result null).\n    // Allows to map command arguments to method parameters and operation context\n    Do(LambdaExpression expression)\n    ```\n    \n    - others operation methods prototypes that are accepted:\n\n    ```csharp\n    // with no parameter and void result delegate\n    Do(Action @delegate)\n\n    // with no parameter and void result delegate\n    Do(Func\u003cOperationResult\u003e @delegate)\n\n    // with parameter operation context and void delegate\n    Do(Action\u003cCommandContext\u003e @delegate)\n\n    // with parameter operation context and OperationResult result delegate\n    Do(Func\u003cCommandContext, OperationResult\u003e @delegate)\n    ```\n\n    - the lambda expression in the method style `Do(LambdaExpression expression)` can have one of these profiles:\n\n        - the most practical is the use of concrete values types (not Opt,Param,.. but the values types inside it):\n\n    ```csharp\n    // arguments mapping to concrete types\n    // also accepts an CommandContext parameter placed anywhere\n    // also accepts explicit mapping of arguments, with positional references in syntax, and no result\n    // avoid repeating the command arguments declarations (Param, Opt)\n    void MyOperation( string arg0, bool arg1 , ..)\n    ```\n\n        - others lambda expressions prototypes that are accepted:\n\n    ```csharp\n    // no parameter and no result\n    void MyOperation()\n\n    // explicit mapping of arguments, with positional references in syntax, and no result\n    void MyOperation([MapArg(1) Param\u003cstring\u003e arg0,[MapArg(5)] Opt\u003cbool\u003e arg1)\n\n    // implicit mapping of arguments and no result\n    // expected arguments (arguments having expected valie(s)) are mapped according to their declaring order\n    void MyOperation(Param\u003cstring\u003e arg0,Opt\u003cbool\u003e arg1)\n\n    // can also have an auto-mapped parameter to the operation context:\n    // a parameter of type CommandContext can be placed anywhere in the parameters list\n    void MyOperation(...,CommandContext context,..)    \n    ```\n\n* methods **`For`** can be chained\n* the method **`Options`** can be chained to a **For**. This method allows to declare the command global options (avalaible for any syntax of the command) :\n    ```csharp\n    Options(params IOpt[] options)\n    ```\n* the method **`With`** launch the command executing process. First command line parsing, then syntax matching, then operation dispatch:\n    ```csharp\n    With(ArgSet args)\n    ```\n\n### Arguments to concrete types mapping of `Do(LambdaExpression expression)` expression parameters:\n\n#### Flags\n\n| argument constructor | possible corresponding type(s) |\n|---|---|\n| `Flag(\"argName\")` | `bool` |\n| `Flag(\"argName\",isOptional: true)` | `bool` |\n\n#### Options\n\n| argument constructor | possible corresponding type(s) |\n|---|---|\n| `Opt(\"argName\")` \u003cbr\u003e `Opt(\"argName\",valueCount:0)`  | as it is expected to exactly match the syntax **argName** (expected values count = 0), this arg must not be mapped |\n| `Opt(\"argName\",isOptional: true)` \u003cbr\u003e `Opt(\"argName\",isOptional: true,valueCount:0)` | `bool` (because expected values count = 0, acts as `Flag` in that case) |\n| | |\n| `Opt(\"argName\",valueCount:1)` | `string` |\n| `Opt(\"argName\",isOptional: true,valueCount:1)` | `string?` or null |\n| | |\n| `Opt(\"argName\",valueCount:2..n)` | `List\u003cstring\u003e` |\n| `Opt(\"argName\",isOptional: true,valueCount:2..n)` | `List\u003cstring\u003e?` or null |\n| | |\n| `Opt\u003cT\u003e(\"argName\",valueCount:0)` | as it is expected to exactly match the syntax **argName** (expected values count = 0), this arg must not be mapped |\n| `Opt\u003cT\u003e(\"argName\",isOptional: true,valueCount:0)` | `bool` (because expected values count = 0, acts as `Flag` in that case) |\n| | |\n| `Opt\u003cT\u003e(\"argName\")` \u003cbr\u003e `Opt\u003cT\u003e(\"argName\",valueCount:1)` | `T` |\n| `Opt\u003cT\u003e(\"argName\",isOptional: true)` \u003cbr\u003e `Opt\u003cT\u003e(\"argName\",isOptional: true,valueCount:1)` | `T?` or default |\n| `Opt\u003cT\u003e(\"argName\",valueCount:2..n)` | `List\u003cT\u003e` |\n| `Opt\u003cT\u003e(\"argName\",isOptional: true,valueCount:2..n)` | `List\u003cT\u003e?` or null |\n\n#### Parameters\n\n| argument constructor | possible corresponding type(s) |\n|---|---|\n| `Param()` | `string` |\n| `Param_T()` | `T` |\n| `Param(\"keyWord\")` | as it is expected to exactly match the syntax **keyWord**, this arg must not be mapped |\n\n### Exemple of the command `help` defined in `CommandLine.NetCore.Commands.CmdLine`:\n\n```csharp\n// command syntax: help [commandName] [-v] [--info]\ninternal sealed class Help : Command\n{\n    protected override CommandResult Execute(ArgSet args) =\u003e\n\n        // syntax: help\n        For()\n            .Do(() =\u003e DumpHelpForAllCommands)\n\n        // syntax: help {commandName}\n        .For(Param())\n            .Do(() =\u003e DumpCommandHelp)\n\n        // any syntax accepts -v and/or --info\n        .Options(Opt(\"v\"), Opt(\"info\"))\n\n        // parse and run\n        .With(args);\n\n    \n    private void DumpCommandHelp(string commandName, bool verbose, bool info)\n    {\n        // ...\n    }\n\n    private void DumpHelpForAllCommands(bool verbose, bool info)\n    {\n        // ...\n    }\n}\n```\n\n### Exemple of the command `get-info` defined in `CommandLine.NetCore.Example.Commands.GetInfo`:\n\n```csharp\n// syntax: get-info (env -l) | (env {varName}) | console | system | --all\ninternal sealed class GetInfo : Command\n{\n    protected override CommandResult Execute(ArgSet args) =\u003e\n\n        // syntax: get-info env -l\n        For(\n            Param(\"env\"),\n            Opt(\"l\")\n            )\n                .Do(DumpAllVars)\n\n        // syntax: get-info env {varName}\n        .For(\n            Param(\"env\"),\n            Param())\n                .Do(() =\u003e DumpEnvVar)\n\n        // syntax: get-info console\n        .For(\n            Param(\"console\"))\n                .Do(DumpConsole)\n\n        // syntax: get-info system\n        .For(\n            Param(\"system\"))\n                .Do(DumpSystem)\n\n        // syntax: get-info --all\n        .For(\n            Opt(\"all\"))\n                .Do(DumpAll)\n\n        // parse and run\n        .With(args);\n\n    private void DumpEnvVar(string envVarName)\n    {\n        // ...\n    }\n}\n```\n\n### 4.2. Implementing a classless command with a lambda expression\n\nYou can dynamically declares and specify a command directly with `CommandLineInterfaceBuilder` fluent methods:\n\n* **`AddCommand`** adds a new dynamic command named *commandName* that is specified by the delegate type `DynamicCommandSpecificationDelegate` \n\n```csharp\nCommandInterfaceBuilder AddCommand( commandName , DynamicCommandSpecificationDelegate )\n```\n\n* the delegate `DynamicCommandSpecificationDelegate` provides a `CommandBuilder` and a `DynamicCommandContext` that provides methods for specify and implements the dynamic command\n    \n    ```chsarp\n    (builder, ctx) =\u003e ...\n    ```\n\nThe `CommandBuilder` exposes the following methods:\n\n* the **`For`** method is the way to specify a command arguments, help and body (it is the same than in the abstract class `Command`)\n\n```csharp\nSyntaxExecutionDispatchMapItem For(params Arg[] syntax)\n```\n\n* methods for building arguments: **`Opt`**, **`Flag`**, **`Param`**, **`OptSet`**\n\n* **`Help`** for dynamically (outside of appsettings) declares the command syntax help:\n\n```csharp\nCommandBuilder Help(string text, string? culture = null)\n```\n\n* **`Tag`** associates one or several tags to the command specification\n* **`Package`** specify a package the command belongs to\n\nThe `SyntaxExecutionDispatchMapItem` has now specific methods for building dynamic commands:\n\n* new `Do` methods with generic types that takes an **Action delegate** as the command implementation\n\n```csharp\nSyntaxMatcherDispatcher Do\u003cT1\u003e(Action\u003cT1\u003e action)\nSyntaxMatcherDispatcher Do\u003cT1, T2\u003e(Action\u003cT1, T2\u003e action)\n...\nSyntaxMatcherDispatcher Do\u003cT1, T2, T3, T4, T5, T6, T7, T8, T9, T10\u003e(Action\u003cT1, T2, T3, T4, T5, T6, T7, T8, T9, T10\u003e action)\n```\n\n* new `Do` for commands with returns (pending impl.)\n\n```csharp\nSyntaxMatcherDispatcher Do(Func\u003cCommandContext, CommandLineResult\u003e @delegate)\n```\n\n* **`Help`** for dynamically (outside of appsettings) declares the command syntax help:\n\n```csharp\nSyntaxExecutionDispatchMapItem Help(\n        string argsSyntax,\n        string description,\n        string? culture = null)\n```\n\n### Example of the command `add` defined in `CommandLine.NetCore.Example.Program`:\n\n```csharp\n// the command line interface builder still loads commands defined in classes\nnew CommandLineInterfaceBuilder()\n\n    // we add a command dynamically specified\n    .AddCommand(\"add\", (builder, ctx) =\u003e builder\n\n        .Help(\"add operator\")\n        .Tag(Tags.Math, Tags.Text)\n\n        .For(builder.Param\u003cint\u003e(), builder.Param\u003cint\u003e(), builder.Param\u003cint\u003e())\n            .Help(\"x y z\", \"returns x+y+z\")\n            .Do((int x, int y, int z) =\u003e\n            {\n                ctx.Console.Out.WriteLine($\"{x}+{y}+{z}={x + y + z}\");\n            })\n\n        .For(builder.Param\u003cint\u003e(), builder.Param\u003cint\u003e())\n            .Help(\"x y\", \"returns x+y\")\n            .Do((int x, int y) =\u003e\n            {\n                ctx.Console.Out.WriteLine($\"{x}+{y}={x + y}\");\n            })\n\n        // ...\n```\n\n## 5. Setup an unique command console app (without command argument)\n0\nYou can prepare a console application that run immediately a specific command at launch and that doesn't requires a command name argument,\nby activating this option in the **main** of your app or using **top level statements** as shown below:\n\n`Program.cs`\n\n```csharp\nusing CommandLine.NetCore.Services.CmdLine;\n\nnew CommandLineInterfaceBuilder()\n\n    // add this for single command mode (here: only get-info, no global help)\n    // case of a class command\n    .ForCommand\u003cGetInfo\u003e()\n    // case of a dynamic command (here: only add, no global help)\n    //.ForCommand(\"add\")\n\n    // add this to avoid global help of the command line parser\n    .DisableGlobalHelp()\n    \n    .Build(args)\n    .Run();\n```\n\nThis example will produce an executable that do not accept a **`command name parameter`** neither the **`help`** global command.\nIf the program is compiled as `MyConsoleApp.exe` the following command lines are accepted:\n\n- get help about the get-info command:\n\n```dos\nMyConsoleApp.exe -h\n```\n\n```dos\n┌──────────────────────────────────────────────────┐\n│ CommandLine.NetCore.Example (1.0.9.0 05/08/2023) │\n└──────────────────────────────────────────────────┘\n\nsample command that output informations about system and console\n\n-h : help about this command\n--all : output all infos\nconsole : dump infos about console\nenv -l : list of environment variables names and values\nenv varName : dump environment variable value with name varName\nsystem : dump infos about system\n```\n\n- run the get-info command:\n\n```dos\nMyConsoleApp.exe system\n```\n\n```dos\nsystem informations:\n\nOperanting System = Microsoft Windows NT 10.0.22621.0\nProcArch = AMD64\nProcessor Model = Intel64 Family 6 Model 165 Stepping 2, GenuineIntel\nProcessor Level = 6\nSystem Directory = C:\\WINDOWS\\system32\nProcessor Count = 12\nUser Domain Name = LAPTOP-R3538U70\nUser Name = franc\nVersion = 6.0.20\nC:\\ =\nC:\\ Volume Label = Windows\nC:\\ Drive Type = Fixed\nC:\\ Drive Format = NTFS\nC:\\ Total Size = 511280410624\nC:\\ Available FreeSpace = 98612314112\n```\n\n## 6. Command classes attributes\n\n- **`[IgnoreCommand]`** : if placed above a command class declaration, the command will be ignored by the command classes loader\n- **`[Tag(tag1,..,tagn)]`** : when placed above a command class declaration, this associates one or several tags to the command specification\n- **`[Package(name)]`** : when placed above a command class declaration, specify that the command belongs to a named package. When not specified, command package is `global`\n\n## 7. Debug and troobleshoot\n\n### Integrated options\n\nIntegrated command line parser options may help the command developer to fix issues:\n\n#### parser traces\n\n`--parser-logging logLevel` enable display of parser syntaxes analysis detailed informations. Possibles values from Microsoft.Extensions.Logging.LogLevel. \nIf `Trace` or `Debug` the parser add detailed informations about the parsed syntaxes\n\n```csharp\nCommandLine.NetCore.Example.exe help --parser-logging Debug\n\nHelpAboutCommandSyntax: 0:Opt\u003cString\u003e-h 1:Opt?\u003cString\u003e-v 2:Opt?\u003cString\u003e--info 3:Opt?\u003cString\u003e-v 4:Opt?\u003cString\u003e--info : match=False\nDumpHelpForAllCommands: 0:Opt?\u003cString\u003e-v 1:Opt?\u003cString\u003e--info 2:Opt?\u003cString\u003e-v 3:Opt?\u003cString\u003e--info : match=True\nDumpCommandHelp: 0:Param\u003cString\u003e? 1:Opt?\u003cString\u003e-v 2:Opt?\u003cString\u003e--info 3:Opt?\u003cString\u003e-v 4:Opt?\u003cString\u003e--info : match=False\n```\n\n#### parser setup\n\n`--exclude-ambiguous-syntax` exclude any ambiguous syntax when parsing command line arguments. By default, the first matching syntax is selected in the command line arguments parser. \nIf this option is set syntaxes of a command can't be ambiguous\n\n# Versions history\n\n`1.0.28,1.0.29,1.0.30` - 04/11/2024\n- AppHostBuilder call ConfigureDelegate prior to configure\n\n`1.0.27` - 02/16/2024\n- add ignore class command method by type and by name\n- add echo option --no-cr\n- Flag default is optional set to true\n\n`1.0.24,1.0.25,1.0.26` - 02/16/2024\n- add french translation appSettings.core.fr-FR.json\n- fix nuget content files\n- update lib ansi\n\n`1.0.22`,`1.0.23` - 02/14/2024\n- fix version number of app in help title box\n\n`1.0.21` - 02/12/2024\t\t\n- add support for environment variables. switch config by environment from DOTNET_ENVIRONMENT\n- fix AppHostConfiguration service registering\n\n`1.0.20` - 02/12/2024\t\t\n- add support for settings with Environment name\n\n`1.0.19` - 02/01/2024\t\t\n- fix command get-info --all syntax was not recognized\n\n`1.0.18` - 02/01/2024\n- fix bug command without tag not displayed in help command list\n\n`1.0.12,1.0.13,1.0.14,1.0.15,1.0.16,1.0.17` - 02/01/2024\n- set Opt default value count to 1 (distinguish from Flag)\n- fix nullable parameter identification in case of classes (string, ..)\n- add command class attribute Tag,Namespace,Package + dynamic commands specification method Tag,Namespace,Package\n- fix dynamic commands set injection scope\n- /!\\ breaking change: removed class CommandLineResult, use CommandResult instead\n- add tests project\n- improve help display\n- fix nuget\n- fix help -t behavior\n- doc update\n\n`1.0.11` - 10/01/2024 (since 09/12/2023)\n- add possiblity to declare and implement a command using uniquely a fluent syntax and no class (dynamic commands)\n- add support for actions with typed parameters in SyntaxExecutionDispatchMapItem\n- fix value was not nullable in Param_T when T is not a class, for instance, Param{int} always had value 0 (=default(T))\n- add ignore command attribute\n- more properties in CommandContext\n- add initialization errors collect and display\n- renamings (eg. OperationResult)\n- update as consts of null syntax name and null value text\n- add support of dynamic and localized configuration\n- fix help support of dynamic polymorphic commands syntaxes\n- doc update\n\n`1.0.10` - 08/11/2023\n- add support of mapping to array parameters when possible (instead of List) in command lambda operations\n- add global option --disable-global-help\n- doc update\n\n`1.0.9` - 08/06/2023\n- add support of mapping for parameters having arguments concrete values types in command lambda operation (not Opt,Param,.. but the values types inside it)\n- fix bug GetValue when not setted option\n- migrate help,test and get-info commands operations methods with concrete type mapping\n- improve mapping errors feedback\n- add SyntaxMatcherDispatcherException and subclasses\n\n`1.0.8` - 01/14/2023\n- add single command mode allowing to build an executable for only one command and eventually without the global help\n- change editor config and code cleanup\n- packages update\n\n`1.0.7` - 01/13/2023\n- add global option `--no-color` that turn off ansi/vt outputs\n- fix auto syntax -h was not passing global arguments\n- new RunCommand in current host\n- improve help output\n- embed symbols and sources\n\n`1.0.6` - 01/11/2023\n- fix MAJOR bug in command options parsing. Were not recongnized correctly\n- `AppHostBuilder` moved to namespace `CommandLine.NetCore.Services.AppHost`\n- fix auto command -h (Command.RunCommand) didn't call back configure and build delegates\n- fix support of -v and --info in -h auto syntax\n- doc update\n\n`1.0.5` - 01/05/2023\n- fix nupkg: adding the package to a project now deploy files Config/appSettings.core.json, LICENSE.md, README.md, assets/ascii-icon.png in your project. These files are configured as 'Content' and are deployed in the `bin` folder. \nYou can remove any of these files **EXCEPT Config/appSettings.core.json** wich is mandatory since it contains the CommandLine.NetCore parser root configuration\n- fix doc\n\n`1.0.4` - 01/04/2023\n- fix nupkg\n\n`1.0.3` - 01/04/2023\n- fix nupkg\n\n`1.0.2` - 01/04/2023\n- fix doc\n\n`1.0.1` - 01/04/2023\n- add CommandContext to lambda operations method\n- add support of abstract classes that inherits from command\n- rename CommandContext by CommandContext\n- fix bug command options were always set in delegate for -h\n\n`1.0.0` - 03/01/2023\n- init\n\n___\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranck-gaspoz%2Fcommandline.netcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranck-gaspoz%2Fcommandline.netcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranck-gaspoz%2Fcommandline.netcore/lists"}