![]() Support for ATM was removed beginning in Windows Vista, making the atmadm command unnecessary. ![]() The atmadm command is available in Windows XP. The atmadm command is used to display information related to asynchronous transfer mode (ATM) connections on the system. Beginning in Windows 8, command line task scheduling should instead be completed with the schtasks command. The at command is available in Windows 7, Windows Vista, and Windows XP. The at command is used to schedule commands and other programs to run at a specific date and time. The assoc command is available in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP. The assoc command is used to display or change the file type associated with a particular file extension. The arp command is available in all versions of Windows. The arp command is used to display or change entries in the ARP cache. The append command is not available in 64-bit versions of Windows. The append command is available in MS-DOS as well as in all 32-bit versions of Windows. ![]() language An option that must be one of the values of a static list.The append command can be used by programs to open files in another directory as if they were located in the current directory. The options section of command help shows the valid values: Options: Here's an example of command-line input and the resulting output for the preceding example code: myapp -language not-a-languageĪrgument 'not-a-language' not recognized. "An option that that must be one of the values of a static list.") To specify a list of valid values for an option or argument, specify an enum as the option type or use FromAmong, as shown in the following example: var languageOption = new Option( In the following example, the value three would be passed to the app. It allows you to repeat an option but takes only the last value on the line. The same setting has a different effect if maximum argument arity is 1. This setting lets you enter the following command line. To allow multiple arguments without repeating the option name, set Option.AllowMultipleArgumentsPerToken to true. System.CommandLine automatically determines the argument arity based on the argument type: Argument typeīy default, when you call a command, you can repeat an option name to specify multiple arguments for an option that has maximum arity greater than one. You can explicitly set argument arity by using the Arity property, but in most cases that is not necessary. ?, -h, -help Show help and usage information The options section of this example's command help omits the -endpoint option. RootCommand.SetHandler((delayOptionValue, messageOptionValue) =>Ĭonsole.WriteLine($"-delay = ("-message", "An option whose argument is parsed as a string.") The command handler code displays the values of those options: var delayOption = new Optionĭescription: "An option whose argument is parsed as an int.", The option names include double-hyphen prefixes, in accordance with POSIX conventions. The following example creates two options and adds them to the root command. The innermost subcommand in this example can be invoked like this: myapp sub1 sub1aĪ command handler method typically has parameters, and the values can come from command-line options. Var sub1aCommand = new Command("sub1a", "Second level subcommand") Var sub1Command = new Command("sub1", "First-level subcommand") You can add subcommands as shown in the following example: var rootCommand = new RootCommand() Var rootCommand = new RootCommand("Sample command-line app") Ĭommands can have child commands, known as subcommands or verbs, and they can nest as many levels as you need. The simplest case for invoking your code, if you have an app with no subcommands, options, or arguments, would look like this: using System.CommandLine ![]() Define a root commandĮvery command-line app has a root command, which refers to the executable file itself. To build a complete application that illustrates these techniques, see the tutorial Get started with System.CommandLine.įor guidance on how to design a command-line app's commands, options, and arguments, see Design guidance. This article explains how to define commands, options, and arguments in command-line apps that are built with the System.CommandLine library. 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 |