![]() For example, the following command errors because "silent" isn't one of the valid values for -verbosity: dotnet build -verbosity silentĬannot parse argument 'silent' for option '-v' as expected type ''. If the argument is not provided, the command fails.Īrguments can have expected types, and System.CommandLine displays an error message if an argument can't be parsed into the expected type. NET CLI, -output requires a folder name argument. ![]() The following command-line examples are equivalent: dotnet tool update dotnet-suggest -globalĭotnet tool update dotnet-suggest -global true For example, many options are implicitly Boolean parameters with a default of true when the option name is in the command line. dotnet tool update dotnet-suggest -verbosity quiet -globalĪrguments can have default values that apply if no argument is explicitly provided. The following examples show an argument for the verbosity option and an argument for the build command. ArgumentsĪn argument is a value passed to an option or a command. When you configure an option, you specify the option name including the prefix. System.CommandLine supports both POSIX and Windows prefix conventions. Options that have no value specified are typically Boolean parameters that default to true if the option is specified on the command line.įor some Windows command-line apps, you identify an option by using a leading slash ( /) with the option name. The following example shows two options: dotnet tool update dotnet-suggest -verbosity quiet -globalĪs this example illustrates, the value of the option may be explicit ( quiet for -verbosity) or implicit (nothing follows -global). The POSIX convention is to prefix the option name with two hyphens ( -). ![]() ![]() OptionsĪn option is a named parameter that can be passed to a command. In dotnet tool install, install is a subcommand of tool. Subcommands can have their own subcommands. For example, the dotnet command has a run subcommand that you invoke by entering dotnet run. Most command-line apps support subcommands, also known as verbs. For example, the dotnet command specifies the dotnet.exe executable. The root command is the one that specifies the name of the app's executable. There are other tool-related commands, such as tool uninstall, tool list, and tool update. In dotnet tool install, install is a command that specifies an action, and tool is a command that specifies a group of related commands.In dotnet run, run is a command that specifies an action.Here's an example: dotnet tool search "ef migrations add"Ī command in command-line input is a token that specifies an action or defines a group of related actions. The following table shows how System.CommandLine interprets the preceding example: TokenĪ token can contain spaces if it's enclosed in quotation marks ( "). The command-line app that is being invoked determines how the tokens after the first one are interpreted. Tokens are interpreted as commands, options, or arguments. This input is parsed by the dotnet application into tokens tool, install, dotnet-suggest, -global, -verbosity, and quiet. For example, consider the following command line: dotnet tool install dotnet-suggest -global -verbosity quiet System.CommandLine parses command-line input into tokens, which are strings delimited by spaces. The information will be useful to users as well as developers of. This article explains the command-line syntax that System.CommandLine recognizes. Microsoft makes no warranties, express or implied, with respect to the information provided here. Some information relates to prerelease product that may be substantially modified before it's released. ![]() System.CommandLine is currently in PREVIEW, and this documentation is for version 2.0 beta 4. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |