Sabamiso.dll-Help.xml
|
<?xml version="1.0" encoding="utf-8"?> <helpItems xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" schema="maml" xmlns="http://msh"> <command:command> <command:details> <command:name>Get-NativeCompleterScript</command:name> <maml:description> <maml:para>Enumerate completer script files.</maml:para> </maml:description> <command:verb>Get</command:verb> <command:noun>NativeCompleterScript</command:noun> </command:details> <maml:description> <maml:para>If nothing is specified, enumerate the loaded completer scripts.</maml:para> <maml:para>The `-All` option lists scripts that have not yet been loaded. You can also filter by command name, and wildcards can be used for this.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-NativeCompleterScript</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>All</maml:name> <maml:description> <maml:para>Get all scripts, including those that haven't been loaded yet.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="true" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Filter results to show only scripts that match the specified value.</maml:para> <maml:para>Can use wildcards such as `*`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>All</maml:name> <maml:description> <maml:para>Get all scripts, including those that haven't been loaded yet.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="true" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Filter results to show only scripts that match the specified value.</maml:para> <maml:para>Can use wildcards such as `*`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Sabamiso.CompleterScript</maml:name> </dev:type> <maml:description> <maml:para>An object with the following properties: - `Name`: File name (command name) without the file extension - `Status`: Indicates whether it is being loaded - `File`: Full path to the script</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. Get loaded scripts ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-NativeCompleterScript ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2. Get all scripts contains not loaded ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-NativeCompleterScript -All ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3. Listing completer scripts for commands starting with "g" ---------</maml:title> <maml:introduction> <maml:para>```powershell Get-NativeCompleterScript g* -All ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>New-ArgumentCompleter</command:name> <maml:description> <maml:para>Create an argument definition for commands and parameters. An argument definition consists of: - **Basic properties** - `Name` - `Description` - `Nargs` - `List` - **One (and only one) completer source** - `Type` - `Candidates` - `Script` > [!NOTE] > `Type`, `Candidates`, and `Script` are *mutually exclusive*. > Only one of them can be specified in a single argument definition.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>ArgumentCompleter</command:noun> </command:details> <maml:description> <maml:para>Create argument definitions to be used with the `New-CommandCompleter` (`Register-NativeCompleter`) command and the `New-ParamCompleter` parameter</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-ArgumentCompleter</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Description for the argument.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>List</maml:name> <maml:description> <maml:para>Indicates that the argument is a comma-separated list.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Name of this argument variable.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Nargs</maml:name> <maml:description> <maml:para>Specifies how many argument values the parameter accepts.</maml:para> <maml:para>e.g.:</maml:para> <maml:para>- "2" — exactly two values - "1+" — one or more values - "2-4" — between two and four values - "?" — zero or one values (flag-or-value). This is same as "0-1"</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Nargs</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-ArgumentCompleter</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Description for the argument.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>List</maml:name> <maml:description> <maml:para>Indicates that the argument is a comma-separated list.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Name of this argument variable.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Nargs</maml:name> <maml:description> <maml:para>Specifies how many argument values the parameter accepts.</maml:para> <maml:para>e.g.:</maml:para> <maml:para>- "2" — exactly two values - "1+" — one or more values - "2-4" — between two and four values - "?" — zero or one values (flag-or-value). This is same as "0-1"</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Nargs</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>Argument type for completion.</maml:para> <maml:para>- **`File`**: Performs a file or directory path completion. - **`Directory`**: Performs directory path completion. - **`Command`**: Performs command or file completion. - **`DelegatingCommand`**: Same as `Command`, but subsequent arguments are passed to that command. (used for like such as `sudo` and `time`)</maml:para> <maml:para>This parameter belongs to the `WithType` parameter set and cannot be used together with `-Candidates` or `-Script`.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.ArgumentType</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-ArgumentCompleter</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Description for the argument.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>List</maml:name> <maml:description> <maml:para>Indicates that the argument is a comma-separated list.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Name of this argument variable.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Nargs</maml:name> <maml:description> <maml:para>Specifies how many argument values the parameter accepts.</maml:para> <maml:para>e.g.:</maml:para> <maml:para>- "2" — exactly two values - "1+" — one or more values - "2-4" — between two and four values - "?" — zero or one values (flag-or-value). This is same as "0-1"</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Nargs</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Script</maml:name> <maml:description> <maml:para>Script for dynamically generating autocomplete candidates.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Management.Automation.ScriptBlock</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-ArgumentCompleter</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Candidates</maml:name> <maml:description> <maml:para>Array of static completion candidates.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.CompletionValue[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Description for the argument.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>List</maml:name> <maml:description> <maml:para>Indicates that the argument is a comma-separated list.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Name of this argument variable.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Nargs</maml:name> <maml:description> <maml:para>Specifies how many argument values the parameter accepts.</maml:para> <maml:para>e.g.:</maml:para> <maml:para>- "2" — exactly two values - "1+" — one or more values - "2-4" — between two and four values - "?" — zero or one values (flag-or-value). This is same as "0-1"</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Nargs</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Candidates</maml:name> <maml:description> <maml:para>Array of static completion candidates.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.CompletionValue[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Description for the argument.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>List</maml:name> <maml:description> <maml:para>Indicates that the argument is a comma-separated list.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Name of this argument variable.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Nargs</maml:name> <maml:description> <maml:para>Specifies how many argument values the parameter accepts.</maml:para> <maml:para>e.g.:</maml:para> <maml:para>- "2" — exactly two values - "1+" — one or more values - "2-4" — between two and four values - "?" — zero or one values (flag-or-value). This is same as "0-1"</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Nargs</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Script</maml:name> <maml:description> <maml:para>Script for dynamically generating autocomplete candidates.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.Management.Automation.ScriptBlock</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Type</maml:name> <maml:description> <maml:para>Argument type for completion.</maml:para> <maml:para>- **`File`**: Performs a file or directory path completion. - **`Directory`**: Performs directory path completion. - **`Command`**: Performs command or file completion. - **`DelegatingCommand`**: Same as `Command`, but subsequent arguments are passed to that command. (used for like such as `sudo` and `time`)</maml:para> <maml:para>This parameter belongs to the `WithType` parameter set and cannot be used together with `-Candidates` or `-Script`.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.ArgumentType</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Sabamiso.ArgumentCompleterWithType</maml:name> </dev:type> <maml:description> <maml:para /> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>Sabamiso.ArgumentCompleterWithCandidates</maml:name> </dev:type> <maml:description> <maml:para /> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>Sabamiso.ArgumentCompleterWithScript</maml:name> </dev:type> <maml:description> <maml:para /> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. Create an argument definition (non-completer) ---------</maml:title> <maml:introduction> <maml:para>```powershell New-ArgumentCompleter -Name arg ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2. Create a flag-or-value definition ---------</maml:title> <maml:introduction> <maml:para>```powershell New-ArgumentCompleter -Name opt -Nargs '?' ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3. Create a file path argument completer ---------</maml:title> <maml:introduction> <maml:para>```powershell New-ArgumentCompleter -Name path -Type File ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4. Create an argument completer from static completion candidates ---------</maml:title> <maml:introduction> <maml:para>```powershell New-ArgumentCompleter -Name animal -Candidates "dog", "cat" ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 5. Create a dynamic argument completer with ScriptBlock ---------</maml:title> <maml:introduction> <maml:para>```powershell New-ArgumentCompleter -Name animal -Script { param([string] $wordToComplete, [int] $offsetPosition, [int] $argumentIndex) $q = $wordToComplete + "*" "dog", "cat" | Where-Object { $_ -like $q } } ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-ParamCompleter</maml:linkText> <command:uri>./New-ParamCompleter.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-CommandCompleter</maml:linkText> <command:uri>./New-CommandCompleter.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-Sabamiso</maml:linkText> <command:uri>./Register-Sabamiso.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>New-CommandCompleter</command:name> <maml:description> <maml:para>Create a CommandCompleter object.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>CommandCompleter</command:noun> </command:details> <maml:description> <maml:para>Create a CommandCompleter object and output. Unlike `Register-NativeCompleter`, it does not register the completer.</maml:para> <maml:para>Typically, this command will be used for creating subcommands. It would be easier to use `Register-NativeCompleter`, which can also be registered for normal commands.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-CommandCompleter</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Aliases</maml:name> <maml:description> <maml:para>Alias names for the command.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para>Specifies argument definitions and their associated completers.</maml:para> <maml:para>The -Arguments parameter accepts values of several types: - A `string` of variable name (alias to `@{ Name = "string" }`) - An object implementing `IArgumentCompleter` - A `Hashtable` (automatically converted to an `IArgumentCompleter`) See following examples.</maml:para> <maml:para>If omitted, standard file‑system path completion is used, unless `-NoFileCompletions` is specified.</maml:para> <maml:para>For examples:</maml:para> <maml:para>```powershell # Perform file‑path completion for one or more arguments New-CommandCompleter ... -Arguments @{ Name = 'path'; Type = 'File'; Nargs = '1+' }</maml:para> <maml:para># Perform autocompletion from a statically defined list New-CommandCompleter ... -Arguments @{ Name = 'animal'; Candidates = "dog", "cat"; }</maml:para> <maml:para># Define separate completers for two arguments New-CommandCompleter ... -Arguments @{ Name = '1st'; Candidates = "A", "B", "C"; }, @{ Name = '2nd'; Candidates = "X", "Y", "Z" }</maml:para> <maml:para># Use a script block for dynamic autocompletion New-CommandCompleter ... -Arguments @{ Name = 'animal'; Script = { param([int] $position, [int] $argumentIndex) # $_ # <- word to complete # $this # <- completion context $prefix = $_.Substring(0, $position) "dog", "cat" | Where-Object { $_ -like "$prefix*" } } } ```</maml:para> <maml:para>For more details, see [Arguments specification](../about_Arguments_spec.md).</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ArgumentCompleterCollection</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>CustomStyle</maml:name> <maml:description> <maml:para>Sets a special non-standard parameter style. This setting is inherited by each parameter.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Command Description. This is primarily used to output a completion list of subcommands.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Command Name</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>NoFileCompletions</maml:name> <maml:description> <maml:para>No file or directory completion in command argument completion.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Parameters</maml:name> <maml:description> <maml:para>List of parameters that can be used in the command or subcommand.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParamCompleter[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Style</maml:name> <maml:description> <maml:para>Style of the command parameters.</maml:para> <maml:para>Availables:</maml:para> <maml:para>- `GNU`: Set long option prefix to `--`, short option prefix to `-` and value spprator to `=`. (Default) - `Windows`: Set short option prefix to `-` and value spprator to `:`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Commands.CommandParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>SubCommands</maml:name> <maml:description> <maml:para>List of subcommands.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.CommandCompleter[]</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Aliases</maml:name> <maml:description> <maml:para>Alias names for the command.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para>Specifies argument definitions and their associated completers.</maml:para> <maml:para>The -Arguments parameter accepts values of several types: - A `string` of variable name (alias to `@{ Name = "string" }`) - An object implementing `IArgumentCompleter` - A `Hashtable` (automatically converted to an `IArgumentCompleter`) See following examples.</maml:para> <maml:para>If omitted, standard file‑system path completion is used, unless `-NoFileCompletions` is specified.</maml:para> <maml:para>For examples:</maml:para> <maml:para>```powershell # Perform file‑path completion for one or more arguments New-CommandCompleter ... -Arguments @{ Name = 'path'; Type = 'File'; Nargs = '1+' }</maml:para> <maml:para># Perform autocompletion from a statically defined list New-CommandCompleter ... -Arguments @{ Name = 'animal'; Candidates = "dog", "cat"; }</maml:para> <maml:para># Define separate completers for two arguments New-CommandCompleter ... -Arguments @{ Name = '1st'; Candidates = "A", "B", "C"; }, @{ Name = '2nd'; Candidates = "X", "Y", "Z" }</maml:para> <maml:para># Use a script block for dynamic autocompletion New-CommandCompleter ... -Arguments @{ Name = 'animal'; Script = { param([int] $position, [int] $argumentIndex) # $_ # <- word to complete # $this # <- completion context $prefix = $_.Substring(0, $position) "dog", "cat" | Where-Object { $_ -like "$prefix*" } } } ```</maml:para> <maml:para>For more details, see [Arguments specification](../about_Arguments_spec.md).</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ArgumentCompleterCollection</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>CustomStyle</maml:name> <maml:description> <maml:para>Sets a special non-standard parameter style. This setting is inherited by each parameter.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Command Description. This is primarily used to output a completion list of subcommands.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Command Name</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>NoFileCompletions</maml:name> <maml:description> <maml:para>No file or directory completion in command argument completion.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Parameters</maml:name> <maml:description> <maml:para>List of parameters that can be used in the command or subcommand.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParamCompleter[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Style</maml:name> <maml:description> <maml:para>Style of the command parameters.</maml:para> <maml:para>Availables:</maml:para> <maml:para>- `GNU`: Set long option prefix to `--`, short option prefix to `-` and value spprator to `=`. (Default) - `Windows`: Set short option prefix to `-` and value spprator to `:`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Commands.CommandParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>SubCommands</maml:name> <maml:description> <maml:para>List of subcommands.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.CommandCompleter[]</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Sabamiso.CommandCompleter</maml:name> </dev:type> <maml:description> <maml:para>Created command completer.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. Create a completer ---------</maml:title> <maml:introduction> <maml:para>```powershell $completer = New-CommandCompleter -Name cmd-name -Description 'command explanation' -Parameters @( New-ParamCompleter -ShortName h -LongName help -Description 'Display help' ) -SubCommands @( New-CommandCompleter -Name sub-command-name -Description '...' # -Parameters ... -SubCommands ... ) ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-Sabamiso</maml:linkText> <command:uri>./Register-Sabamiso.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-ParamCompleter</maml:linkText> <command:uri>./New-ParamCompleter.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>New-ParamCompleter</command:name> <maml:description> <maml:para>Create a parameter's completer.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>ParamCompleter</command:noun> </command:details> <maml:description> <maml:para>Create an object for parameter completion. The created object can be specified in `-Parameters` of `New-CommandCompleter` or `Register-NativeCompleter`.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-ParamCompleter</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para>Specifies argument definitions and their associated completers.</maml:para> <maml:para>The -Arguments parameter accepts values of several types: - A `string` of variable name (alias to `@{ Name = "string" }`) - An object implementing `IArgumentCompleter` - A `Hashtable` (automatically converted to an `IArgumentCompleter`) See following examples.</maml:para> <maml:para>If omitted, standard file‑system path completion is used, unless `-NoFileCompletions` is specified.</maml:para> <maml:para>For examples:</maml:para> <maml:para>```powershell # Perform file‑path completion for one or more arguments New-ParamCompleter -LongName file -Arguments @{ Name = 'path'; Type = 'File'; }</maml:para> <maml:para># Perform autocompletion from a statically defined list New-ParamCompleter -Name favorit -Arguments @{ Name = 'animal'; Candidates = "dog", "cat"; }</maml:para> <maml:para># Define flag-or-value's parameter New-ParamCompleter -LongName color -Arguments @{ Name = 'WHEN'; Nargs = '?'; Candidates = "auto","always","never" }</maml:para> <maml:para># Define separate completers for two arguments New-ParamCompleter -LongName pair -Arguments @{ Name = '1st'; Candidates = "A", "B", "C"; }, @{ Name = '2nd'; Candidates = "X", "Y", "Z" }</maml:para> <maml:para># Use a script block for dynamic autocompletion New-ParamCompleter -Name favorit -Arguments @{ Name = 'animal'; Script = { param([int] $position, [int] $argumentIndex) # $_ # <- word to complete # $this # <- completion context $prefix = $_.Substring(0, $position) "dog", "cat" | Where-Object { $_ -like "$prefix*" } } } ```</maml:para> <maml:para>For more details, see [Arguments specification](../about_Arguments_spec.md).</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ArgumentCompleterCollection</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Parameter description.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>LongName</maml:name> <maml:description> <maml:para>GNU-style's long parameter names.</maml:para> <maml:para>Unless you apply a special `Style`, specify the name without the prefix (`--`). If the parameter is `--verbose`, specify `verbose`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ShortName</maml:name> <maml:description> <maml:para>GNU-style's short parameter names.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Char[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>StandardName</maml:name> <maml:description> <maml:para>Standard parameter names.</maml:para> <maml:para>Unless you apply a special `Style`, specify the name without the prefix (`-` or `/`). If the parameter is `-name`, specify `name`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Style</maml:name> <maml:description> <maml:para>Specify Parameter style. If ommited, inhertes from the parent CommandCompleter's style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterStyle</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para>Specifies argument definitions and their associated completers.</maml:para> <maml:para>The -Arguments parameter accepts values of several types: - A `string` of variable name (alias to `@{ Name = "string" }`) - An object implementing `IArgumentCompleter` - A `Hashtable` (automatically converted to an `IArgumentCompleter`) See following examples.</maml:para> <maml:para>If omitted, standard file‑system path completion is used, unless `-NoFileCompletions` is specified.</maml:para> <maml:para>For examples:</maml:para> <maml:para>```powershell # Perform file‑path completion for one or more arguments New-ParamCompleter -LongName file -Arguments @{ Name = 'path'; Type = 'File'; }</maml:para> <maml:para># Perform autocompletion from a statically defined list New-ParamCompleter -Name favorit -Arguments @{ Name = 'animal'; Candidates = "dog", "cat"; }</maml:para> <maml:para># Define flag-or-value's parameter New-ParamCompleter -LongName color -Arguments @{ Name = 'WHEN'; Nargs = '?'; Candidates = "auto","always","never" }</maml:para> <maml:para># Define separate completers for two arguments New-ParamCompleter -LongName pair -Arguments @{ Name = '1st'; Candidates = "A", "B", "C"; }, @{ Name = '2nd'; Candidates = "X", "Y", "Z" }</maml:para> <maml:para># Use a script block for dynamic autocompletion New-ParamCompleter -Name favorit -Arguments @{ Name = 'animal'; Script = { param([int] $position, [int] $argumentIndex) # $_ # <- word to complete # $this # <- completion context $prefix = $_.Substring(0, $position) "dog", "cat" | Where-Object { $_ -like "$prefix*" } } } ```</maml:para> <maml:para>For more details, see [Arguments specification](../about_Arguments_spec.md).</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ArgumentCompleterCollection</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Parameter description.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>LongName</maml:name> <maml:description> <maml:para>GNU-style's long parameter names.</maml:para> <maml:para>Unless you apply a special `Style`, specify the name without the prefix (`--`). If the parameter is `--verbose`, specify `verbose`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ShortName</maml:name> <maml:description> <maml:para>GNU-style's short parameter names.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Char[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>StandardName</maml:name> <maml:description> <maml:para>Standard parameter names.</maml:para> <maml:para>Unless you apply a special `Style`, specify the name without the prefix (`-` or `/`). If the parameter is `-name`, specify `name`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Style</maml:name> <maml:description> <maml:para>Specify Parameter style. If ommited, inhertes from the parent CommandCompleter's style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterStyle</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Sabamiso.ParamCompleter</maml:name> </dev:type> <maml:description> <maml:para>Created a parameter completer object.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. Create a flag parameter ---------</maml:title> <maml:introduction> <maml:para>```powershell $helpParam = New-ParamCompleter -ShortName h -LongName help -Description 'Display help' ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2. Multiple long parameter names ---------</maml:title> <maml:introduction> <maml:para>```powershell $slientParam = New-ParamCompleter -LongName quiet, slient -Description 'Suppress outputs' ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3. Create Flag or WithValue parameter ---------</maml:title> <maml:introduction> <maml:para>```powershell $colorParam = New-ParamCompleter -LongName color -Arguments @{ Nargs = '?'; Candidates = 'auto','always','never' } ```</maml:para> <maml:para>€</maml:para> <maml:para>Syntax will be: `--color[={auto|always|never}]`</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4. Create a parameter that requires a file path as an argument ---------</maml:title> <maml:introduction> <maml:para>```powershell $fileParam = New-ParamCompleter -LongName file -Arguments @{ Name = 'PATH'; Type = 'File'; } ```</maml:para> <maml:para>€</maml:para> <maml:para>Syntax will be: `--file[ =]PATH` And file name completion will then be enabled.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-NativeCompleter</maml:linkText> <command:uri>Register-NativeCompleter.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-CommandCompleter</maml:linkText> <command:uri>New-CommandCompleter.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>New-ParamStyle</command:name> <maml:description> <maml:para>Create or get parameter style instance.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>ParamStyle</command:noun> </command:details> <maml:description> <maml:para>The `New-ParamStyle` cmdlet allows you to create or retrieve a parameter style instance. This can be used to define how command-line parameters are parsed, including the prefixes for long and short options, the separator for values, and the style of parameter values.</maml:para> <maml:para>You can use predefined styles such as GNU, Windows, or Unix, or define a custom style by specifying the prefixes, separator, and value style.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-ParamStyle</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Specifies the predefined parameter style to use. Valid values are `GNU`, `Windows`, and `Unix`.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.Commands.CommandParameterStyle</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-ParamStyle</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>LongOptionPrefix</maml:name> <maml:description> <maml:para>Specifies the prefix for long options in the custom parameter style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ShortOptionPrefix</maml:name> <maml:description> <maml:para>Specifies the prefix for short options in the custom parameter style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ValueSeparator</maml:name> <maml:description> <maml:para>Specifies the character used to separate options from their values in the custom parameter style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Char</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ValueStyle</maml:name> <maml:description> <maml:para>Specifies the style of parameter values in the custom parameter style.</maml:para> <maml:para>Valid values are `Adjacent`, `Separated`, and `Both`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterValueStyle</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>LongOptionPrefix</maml:name> <maml:description> <maml:para>Specifies the prefix for long options in the custom parameter style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Specifies the predefined parameter style to use. Valid values are `GNU`, `Windows`, and `Unix`.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.Commands.CommandParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ShortOptionPrefix</maml:name> <maml:description> <maml:para>Specifies the prefix for short options in the custom parameter style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ValueSeparator</maml:name> <maml:description> <maml:para>Specifies the character used to separate options from their values in the custom parameter style.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Char</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ValueStyle</maml:name> <maml:description> <maml:para>Specifies the style of parameter values in the custom parameter style.</maml:para> <maml:para>Valid values are `Adjacent`, `Separated`, and `Both`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterValueStyle</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Sabamiso.ParameterStyle</maml:name> </dev:type> <maml:description> <maml:para>Returns an instance of the `ParameterStyle` class representing the created or retrieved parameter style.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. Get builtin `GNU` parameter style ---------</maml:title> <maml:introduction> <maml:para>```powershell New-ParamStyle -Name GNU ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2. Create `Key=Value` parameter style ---------</maml:title> <maml:introduction> <maml:para>```powershell New-ParamStyle -ValueSeparator "=" -ValueStyle Adjacent ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-ParamCompleter</maml:linkText> <command:uri>./New-ParamCompleter.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Register-NativeCompleter</command:name> <maml:description> <maml:para>Create and register a CommandCompleter object.</maml:para> </maml:description> <command:verb>Register</command:verb> <command:noun>NativeCompleter</command:noun> </command:details> <maml:description> <maml:para>Create and **register** a CommandCompleter object.</maml:para> <maml:para>Typically, this command will be used for registering normal commands not subcommands.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Register-NativeCompleter</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Aliases</maml:name> <maml:description> <maml:para>Alias names for the command.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para>Specifies argument definitions and their associated completers.</maml:para> <maml:para>The -Arguments parameter accepts values of several types: - A `string` of variable name (alias to `@{ Name = "string" }`) - An object implementing `IArgumentCompleter` - A `Hashtable` (automatically converted to an `IArgumentCompleter`) See following examples.</maml:para> <maml:para>If omitted, standard file‑system path completion is used, unless `-NoFileCompletions` is specified.</maml:para> <maml:para>For examples:</maml:para> <maml:para>```powershell # Perform file‑path completion for one or more arguments Register-NativeCompleter ... -Arguments @{ Name = 'path'; Type = 'File'; Nargs = '1+' }</maml:para> <maml:para># Perform autocompletion from a statically defined list Register-NativeCompleter ... -Arguments @{ Name = 'animal'; Candidates = "dog", "cat"; }</maml:para> <maml:para># Define separate completers for two arguments Register-NativeCompleter ... -Arguments @{ Name = '1st'; Candidates = "A", "B", "C"; }, @{ Name = '2nd'; Candidates = "X", "Y", "Z" }</maml:para> <maml:para># Use a script block for dynamic autocompletion Register-NativeCompleter ... -Arguments @{ Name = 'animal'; Script = { param([int] $position, [int] $argumentIndex) # $_ # <- word to complete # $this # <- completion context $prefix = $_.Substring(0, $position) "dog", "cat" | Where-Object { $_ -like "$prefix*" } } } ```</maml:para> <maml:para>For more details, see [Arguments specification](../about_Arguments_spec.md).</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ArgumentCompleterCollection</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>CustomStyle</maml:name> <maml:description> <maml:para>Sets a special non-standard parameter style. This setting is inherited by each parameter.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Command Description.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Even if a command with the same name is already registered, it will be forcibly overwritten.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Command Name</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>NoFileCompletions</maml:name> <maml:description> <maml:para>No file or directory completion in command argument completion.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Parameters</maml:name> <maml:description> <maml:para>List of parameters that can be used in the command or subcommand.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParamCompleter[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Style</maml:name> <maml:description> <maml:para>Style of the command parameters.</maml:para> <maml:para>Availables:</maml:para> <maml:para>- `GNU`: Set long option prefix to `--`, short option prefix to `-` and value spprator to `=`. (Default) - `Windows`: Set short option prefix to `-` and value spprator to `:`. - `Unix`: Similer to `GNU`, but disallow adjacent value parameter like `-key=value`</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Commands.CommandParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>SubCommands</maml:name> <maml:description> <maml:para>List of subcommands.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.CommandCompleter[]</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Register-NativeCompleter</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Completer</maml:name> <maml:description> <maml:para>Specify the CommadCompleter object to be registered. Typically, used for registering the command completer which created by `New-CommandCompleter` cmdlet.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.CommandCompleter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Even if a command with the same name is already registered, it will be forcibly overwritten.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Aliases</maml:name> <maml:description> <maml:para>Alias names for the command.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Arguments</maml:name> <maml:description> <maml:para>Specifies argument definitions and their associated completers.</maml:para> <maml:para>The -Arguments parameter accepts values of several types: - A `string` of variable name (alias to `@{ Name = "string" }`) - An object implementing `IArgumentCompleter` - A `Hashtable` (automatically converted to an `IArgumentCompleter`) See following examples.</maml:para> <maml:para>If omitted, standard file‑system path completion is used, unless `-NoFileCompletions` is specified.</maml:para> <maml:para>For examples:</maml:para> <maml:para>```powershell # Perform file‑path completion for one or more arguments Register-NativeCompleter ... -Arguments @{ Name = 'path'; Type = 'File'; Nargs = '1+' }</maml:para> <maml:para># Perform autocompletion from a statically defined list Register-NativeCompleter ... -Arguments @{ Name = 'animal'; Candidates = "dog", "cat"; }</maml:para> <maml:para># Define separate completers for two arguments Register-NativeCompleter ... -Arguments @{ Name = '1st'; Candidates = "A", "B", "C"; }, @{ Name = '2nd'; Candidates = "X", "Y", "Z" }</maml:para> <maml:para># Use a script block for dynamic autocompletion Register-NativeCompleter ... -Arguments @{ Name = 'animal'; Script = { param([int] $position, [int] $argumentIndex) # $_ # <- word to complete # $this # <- completion context $prefix = $_.Substring(0, $position) "dog", "cat" | Where-Object { $_ -like "$prefix*" } } } ```</maml:para> <maml:para>For more details, see [Arguments specification](../about_Arguments_spec.md).</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ArgumentCompleterCollection</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Completer</maml:name> <maml:description> <maml:para>Specify the CommadCompleter object to be registered. Typically, used for registering the command completer which created by `New-CommandCompleter` cmdlet.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Sabamiso.CommandCompleter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>CustomStyle</maml:name> <maml:description> <maml:para>Sets a special non-standard parameter style. This setting is inherited by each parameter.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="none"> <maml:name>Description</maml:name> <maml:description> <maml:para>Command Description.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Even if a command with the same name is already registered, it will be forcibly overwritten.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Command Name</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>NoFileCompletions</maml:name> <maml:description> <maml:para>No file or directory completion in command argument completion.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.SwitchParameter</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Parameters</maml:name> <maml:description> <maml:para>List of parameters that can be used in the command or subcommand.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.ParamCompleter[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Style</maml:name> <maml:description> <maml:para>Style of the command parameters.</maml:para> <maml:para>Availables:</maml:para> <maml:para>- `GNU`: Set long option prefix to `--`, short option prefix to `-` and value spprator to `=`. (Default) - `Windows`: Set short option prefix to `-` and value spprator to `:`. - `Unix`: Similer to `GNU`, but disallow adjacent value parameter like `-key=value`</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.Commands.CommandParameterStyle</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>SubCommands</maml:name> <maml:description> <maml:para>List of subcommands.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">Sabamiso.CommandCompleter[]</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>Sabamiso.CommandCompleter</maml:name> </dev:type> <maml:description> <maml:para>Registers the CommandCompleter input from the pipeline.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Void</maml:name> </dev:type> <maml:description> <maml:para>None of output</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. Register normal command ---------</maml:title> <maml:introduction> <maml:para>```powershell Register-NativeCompleter -Name cmd-name -Parameters @( New-ParamCompleter -ShortName h -LongName help -Description 'Display help' # ... ) ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-CommandCompleter</maml:linkText> <command:uri>./New-CommandCompleter.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-ParamCompleter</maml:linkText> <command:uri>./New-ParamCompleter.md</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Unregister-NativeCompleter</maml:linkText> <command:uri>./Unregister-NativeCompleter.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Unregister-NativeCompleter</command:name> <maml:description> <maml:para>Unregister the command completer.</maml:para> </maml:description> <command:verb>Unregister</command:verb> <command:noun>NativeCompleter</command:noun> </command:details> <maml:description> <maml:para>Unregister the command completer. The unregistered command will again search the directory in the `PS_COMPLETE_PATH` environment variable, and then execute the PowerShell script.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Unregister-NativeCompleter</maml:name> <command:parameter required="true" variableLength="false" globbing="true" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Name of command to be unregistered. Wildcards (`*`) are supported.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="false" globbing="true" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Name of command to be unregistered. Wildcards (`*`) are supported.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">System.String</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Void</maml:name> </dev:type> <maml:description> <maml:para>None of output</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para /> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1. Unregister grep command ---------</maml:title> <maml:introduction> <maml:para>```powershell Unregister-NativeCompleter grep ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2. Unregister all ---------</maml:title> <maml:introduction> <maml:para>```powershell Unregister-NativeCompleter * ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Register-NativeCompleter</maml:linkText> <command:uri>./Register-NativeCompleter.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> </helpItems> |