### Build Project using Command Line Source: https://github.com/dotnet/command-line-api/blob/main/CONTRIBUTING.md Instructions for compiling the .NET command-line API project using platform-specific build scripts. Ensure the .NET SDK is installed and accessible. ```cmd > .\build.cmd ``` ```bash $ ./build.sh ``` -------------------------------- ### Install dotnet-suggest Global Tool Source: https://github.com/dotnet/command-line-api/blob/main/docs/dotnet-suggest.md Installs the dotnet-suggest global tool, which is required to enable tab completion for command-line applications. This command should be run once on the machine where completion is desired. ```sh dotnet tool install -g dotnet-suggest ``` -------------------------------- ### Publish Artifacts with Multiple Outputs in 1ES Templates Source: https://github.com/dotnet/command-line-api/blob/main/eng/common/template-guidance.md This example demonstrates how to configure the 'templateContext' to use the 'Multiple outputs' feature when publishing artifacts with 1ES official pipeline templates. It shows how to gather build outputs into a specified target path within the artifact staging directory, reducing security scan overhead. ```yaml extends: template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate parameters: stages: - stage: build jobs: - template: /eng/common/templates-official/jobs/jobs.yml@self parameters: # 1ES makes use of outputs to reduce security task injection overhead templateContext: outputs: - output: pipelineArtifact displayName: 'Publish logs from source' continueOnError: true condition: always() targetPath: $(Build.ArtifactStagingDirectory)/artifacts/log artifactName: Logs jobs: - job: Windows steps: - script: echo "friendly neighborhood" > artifacts/marvel/spiderman.txt # copy build outputs to artifact staging directory for publishing - task: CopyFiles@2 displayName: Gather build output inputs: SourceFolder: '$(Build.SourcesDirectory)/artifacts/marvel' Contents: '**' TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/marvel' ``` -------------------------------- ### System.CommandLine Argument Class API Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Details the `Argument` class, which represents a command-line argument. It includes properties for arity, completion sources, default values, help name, validators, and value type, along with methods for getting completions and default values. ```APIDOC System.CommandLine.Argument : Symbol Properties: ArgumentArity Arity { get; set; } System.Collections.Generic.List>> CompletionSources { get; } System.Boolean HasDefaultValue { get; } System.String HelpName { get; set; } System.Collections.Generic.List> Validators { get; } System.Type ValueType { get; } Methods: System.Collections.Generic.IEnumerable GetCompletions(System.CommandLine.Completions.CompletionContext context) System.Object GetDefaultValue() System.String ToString() ``` -------------------------------- ### View Build Script Help Source: https://github.com/dotnet/command-line-api/blob/main/CONTRIBUTING.md Command to display available options and usage information for the project's build scripts on Windows or macOS/Linux. ```cmd > .\build.cmd -help ``` ```bash $ ./build.sh --help ``` -------------------------------- ### Run Tests using Command Line Source: https://github.com/dotnet/command-line-api/blob/main/CONTRIBUTING.md Instructions for building and running tests for the .NET command-line API project using platform-specific build scripts. This command executes all defined tests. ```cmd > .\build.cmd -test ``` ```bash $ ./build.sh --test ``` -------------------------------- ### Configure Bash Tab Completion Source: https://github.com/dotnet/command-line-api/blob/main/docs/dotnet-suggest.md Sets up tab completion for Bash. It generates a completion script using dotnet-suggest and sources it in the user's .bashrc file for persistent completion. ```sh dotnet-suggest script bash >~/.dotnet-suggest-shim.bash echo '. ~/.dotnet-suggest-shim.bash' >>~/.bashrc ``` -------------------------------- ### System.CommandLine.Parsing.ParserConfiguration Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Configuration settings for the command line parser, such as POSIX bundling and token replacement. ```C# public class ParserConfiguration // Constructor for ParserConfiguration. .ctor() public System.Boolean EnablePosixBundling { get; set; } // Enables or disables POSIX-style option bundling. ``` ```C# public class ParserConfiguration public System.CommandLine.Parsing.TryReplaceToken ResponseFileTokenReplacer { get; set; } // A delegate for replacing response file tokens. ``` ```C# public class ParseResult public ParserConfiguration Configuration { get; } // The parser configuration used for this result. ``` -------------------------------- ### System.CommandLine.Help Namespace Classes Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Classes for generating and displaying help information for command-line applications. ```APIDOC System.CommandLine.Help.HelpAction : System.CommandLine.Invocation.SynchronousCommandLineAction: MaxWidth { get; set; } : System.Int32 - Gets or sets the maximum width for help output. Invoke(System.CommandLine.ParseResult parseResult): Executes the help action, displaying help information. .ctor(): Constructor for HelpAction. System.CommandLine.Help.HelpOption : System.CommandLine.Option: Action { get; set; } : System.CommandLine.Invocation.CommandLineAction - Gets or sets the action to perform when the option is invoked. ValueType { get; } : System.Type - Gets the type of the value associated with the option. .ctor(): Constructor for HelpOption. .ctor(System.String name, System.String[] aliases): Constructor with custom name and aliases. ``` -------------------------------- ### Configure Zsh Tab Completion Source: https://github.com/dotnet/command-line-api/blob/main/docs/dotnet-suggest.md Sets up tab completion for Zsh. It generates a completion script using dotnet-suggest and sources it in the user's .zshrc file for persistent completion. ```sh dotnet-suggest script zsh >~/.dotnet-suggest-shim.zsh echo '. ~/.dotnet-suggest-shim.zsh' >>~/.zshrc ``` -------------------------------- ### System.CommandLine.Completions Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Provides methods and properties related to command-line argument completions, including context retrieval and completion item generation. ```C# public static System.Void Add(this System.Collections.Generic.List>> completionSources, System.String[] completions) // Extension method to add completion sources to a list. ``` ```C# public class Directive : Symbol public System.Collections.Generic.IEnumerable GetCompletions(System.CommandLine.Completions.CompletionContext context) // Gets completion items for a directive based on the provided context. ``` ```C# public abstract class Option : Symbol public System.Collections.Generic.IEnumerable GetCompletions(System.CommandLine.Completions.CompletionContext context) // Gets completion items for an option based on the provided context. ``` ```C# public class ParseResult public System.Collections.Generic.IReadOnlyList> GetCompletions(System.Nullable position = null) // Gets completion items for the command line input at a specific position. ``` ```C# public class ParseResult public System.CommandLine.Completions.CompletionContext GetCompletionContext() // Creates a completion context from the parse result. ``` -------------------------------- ### System.CommandLine.Completions Namespace Classes Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Classes for managing and providing command-line completion suggestions. ```APIDOC System.CommandLine.Completions.CompletionContext: Empty { get; } : CompletionContext - Gets an empty completion context. ParseResult { get; } : System.CommandLine.ParseResult - Gets the parse result associated with the completion context. WordToComplete { get; } : System.String - Gets the word currently being completed. System.CommandLine.Completions.CompletionItem: Detail { get; } : System.String - Gets additional details for the completion item. Documentation { get; set; } : System.String - Gets or sets documentation for the completion item. InsertText { get; } : System.String - Gets the text to insert for the completion item. Kind { get; } : System.String - Gets the kind of the completion item (e.g., Value, Method). Label { get; } : System.String - Gets the label displayed for the completion item. SortText { get; } : System.String - Gets the text used for sorting completion items. Equals(CompletionItem other): Determines whether the specified CompletionItem is equal to the current object. Equals(System.Object obj): Determines whether the specified object is equal to the current object. GetHashCode(): Serves as the default hash function. ToString(): Returns a string representation of the CompletionItem. .ctor(System.String label, System.String kind = Value, System.String sortText = null, System.String insertText = null, System.String documentation = null, System.String detail = null): Constructor for CompletionItem. System.CommandLine.Completions.SuggestDirective : System.CommandLine.Directive: Action { get; set; } : System.CommandLine.Invocation.CommandLineAction - Gets or sets the action to perform when the directive is encountered. .ctor(): Constructor for SuggestDirective. System.CommandLine.Completions.TextCompletionContext : CompletionContext: CommandLineText { get; } : System.String - Gets the full command line text. CursorPosition { get; } : System.Int32 - Gets the current cursor position within the command line. AtCursorPosition(System.Int32 position): Creates a new TextCompletionContext at a specified cursor position. ``` -------------------------------- ### Command Line Parsing Entry Point Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Provides a static method to parse a command line string into a structured representation. This is the primary entry point for command line parsing operations. ```csharp public static System.Collections.Generic.IEnumerable SplitCommandLine(System.String commandLine) ``` -------------------------------- ### System.CommandLine.Parsing.CommandLineParser Class Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Provides static methods for parsing command-line arguments. ```APIDOC System.CommandLine.Parsing.CommandLineParser: Parse(System.CommandLine.Command command, System.Collections.Generic.IReadOnlyList args, System.CommandLine.ParserConfiguration configuration = null): System.CommandLine.ParseResult - Parses a list of string arguments against a command. Parse(System.CommandLine.Command command, System.String commandLine, System.CommandLine.ParserConfiguration configuration = null): System.CommandLine.ParseResult - Parses a single command line string against a command. ``` -------------------------------- ### System.CommandLine CompletionSourceExtensions API Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Provides extension methods for managing completion sources, specifically for adding custom completion logic to arguments via delegates. ```APIDOC System.CommandLine.CompletionSourceExtensions Extension Methods: System.Void Add(this System.Collections.Generic.List>> completionSources, System.Func> completionsDelegate) ``` -------------------------------- ### System.CommandLine.Option and related validation Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Defines generic options and provides extension methods for validating option arguments, such as accepting only existing file system entries. ```C# public class Option : Option // Constructor for Option. .ctor(System.String name, System.String[] aliases) public System.Type ValueType { get; } // The type of the option's value. ``` ```C# public class Option : Option public Func CustomParser { get; set; } // A custom parser for the option's argument. ``` ```C# public class Option : Option public Func DefaultValueFactory { get; set; } // A factory function to provide the default value. ``` ```C# public class Option : Option public Option AcceptLegalFileNamesOnly() // Configures the option to accept only legal file names. ``` ```C# public class Option : Option public Option AcceptLegalFilePathsOnly() // Configures the option to accept only legal file paths. ``` ```C# public class Option : Option public Option AcceptOnlyFromAmong(System.String[] values) // Configures the option to accept values only from a specified list. ``` ```C# public static class OptionValidation public static Option AcceptExistingOnly(this Option option) // Validates that the option's FileInfo value refers to an existing file. ``` ```C# public static class OptionValidation public static Option AcceptExistingOnly(this Option option) // Validates that the option's DirectoryInfo value refers to an existing directory. ``` ```C# public static class OptionValidation public static Option AcceptExistingOnly(this Option option) // Validates that the option's FileSystemInfo value refers to an existing file or directory. ``` ```C# public static class OptionValidation public static Option AcceptExistingOnly(this Option option) // Generic validation for existing file system entries. ``` -------------------------------- ### System.CommandLine.VersionOption Class Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Represents an option that displays the version of the application. ```APIDOC System.CommandLine.VersionOption : Option: Action { get; set; } : System.CommandLine.Invocation.CommandLineAction - Gets or sets the action to perform when the option is invoked. ValueType { get; } : System.Type - Gets the type of the value associated with the option. .ctor(): Constructor for VersionOption. .ctor(System.String name, System.String[] aliases): Constructor with custom name and aliases. ``` -------------------------------- ### System.CommandLine.Invocation.InvocationConfiguration Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Configuration settings for command line invocation, including exception handling and timeouts. ```C# public class InvocationConfiguration // Constructor for InvocationConfiguration. .ctor() public System.Boolean EnableDefaultExceptionHandler { get; set; } // Enables or disables the default exception handler. ``` ```C# public class InvocationConfiguration public System.IO.TextWriter Error { get; set; } // Specifies the TextWriter for error output. ``` ```C# public class InvocationConfiguration public System.IO.TextWriter Output { get; set; } // Specifies the TextWriter for standard output. ``` ```C# public class InvocationConfiguration public System.Nullable ProcessTerminationTimeout { get; set; } // Sets the timeout for process termination. ``` ```C# public class ParseResult public InvocationConfiguration InvocationConfiguration { get; } // The invocation configuration used for parsing. ``` -------------------------------- ### System.CommandLine ArgumentArity Struct API Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Defines the arity (number of values) for an argument. It provides static properties for common arity configurations like `ExactlyOne`, `ZeroOrMore`, and `ZeroOrOne`, and allows custom instantiation. ```APIDOC System.CommandLine.ArgumentArity : System.ValueType, System.IEquatable Static Properties: ArgumentArity ExactlyOne { get; } ArgumentArity OneOrMore { get; } ArgumentArity Zero { get; } ArgumentArity ZeroOrMore { get; } ArgumentArity ZeroOrOne { get; } Constructors: .ctor(System.Int32 minimumNumberOfValues, System.Int32 maximumNumberOfValues) Properties: System.Int32 MaximumNumberOfValues { get; } System.Int32 MinimumNumberOfValues { get; } Methods: System.Boolean Equals(ArgumentArity other) System.Boolean Equals(System.Object obj) System.Int32 GetHashCode() ``` -------------------------------- ### System.CommandLine Command Class API Source: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt Represents a command in a command-line interface. It can contain arguments, options, and subcommands, and defines an action to be executed when the command is invoked. Includes methods for adding symbols and parsing input. ```APIDOC System.CommandLine.Command : Symbol, System.Collections.IEnumerable Constructors: .ctor(System.String name, System.String description = null) Properties: System.CommandLine.Invocation.CommandLineAction Action { get; set; } System.Collections.Generic.ICollection Aliases { get; } System.Collections.Generic.IList Arguments { get; } System.Collections.Generic.IEnumerable Children { get; } System.Collections.Generic.IList