1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| ❯ miniserve --print-completions powershell
using namespace System.Management.Automation using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'miniserve' -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements $command = @( 'miniserve' for ($i = 1; $i -lt $commandElements.Count; $i++) { $element = $commandElements[$i] if ($element -isnot [StringConstantExpressionAst] -or $element.StringConstantType -ne [StringConstantType]::BareWord -or $element.Value.StartsWith('-') -or $element.Value -eq $wordToComplete) { break } $element.Value }) -join ';'
$completions = @(switch ($command) { 'miniserve' { [CompletionResult]::new('--index', 'index', [CompletionResultType]::ParameterName, 'The name of a directory index file to serve, like "index.html"') [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Port to use') [CompletionResult]::new('--port', 'port', [CompletionResultType]::ParameterName, 'Port to use') [CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'Interface to listen on') [CompletionResult]::new('--interfaces', 'interfaces', [CompletionResultType]::ParameterName, 'Interface to listen on') [CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Set authentication. Currently supported formats: username:password, username:sha256:hash, username:sha512:hash (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)') [CompletionResult]::new('--auth', 'auth', [CompletionResultType]::ParameterName, 'Set authentication. Currently supported formats: username:password, username:sha256:hash, username:sha512:hash (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)') [CompletionResult]::new('--route-prefix', 'route-prefix', [CompletionResultType]::ParameterName, 'Use a specific route prefix') [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Default color scheme') [CompletionResult]::new('--color-scheme', 'color-scheme', [CompletionResultType]::ParameterName, 'Default color scheme') [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Default color scheme') [CompletionResult]::new('--color-scheme-dark', 'color-scheme-dark', [CompletionResultType]::ParameterName, 'Default color scheme') [CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'Enable file uploading (and optionally specify for which directory)') [CompletionResult]::new('--upload-files', 'upload-files', [CompletionResultType]::ParameterName, 'Enable file uploading (and optionally specify for which directory)') [CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Specify uploadable media types') [CompletionResult]::new('--media-type', 'media-type', [CompletionResultType]::ParameterName, 'Specify uploadable media types') [CompletionResult]::new('-M', 'M', [CompletionResultType]::ParameterName, 'Directly specify the uploadable media type expression') [CompletionResult]::new('--raw-media-type', 'raw-media-type', [CompletionResultType]::ParameterName, 'Directly specify the uploadable media type expression') [CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'Shown instead of host in page title and heading') [CompletionResult]::new('--title', 'title', [CompletionResultType]::ParameterName, 'Shown instead of host in page title and heading') [CompletionResult]::new('--header', 'header', [CompletionResultType]::ParameterName, 'Set custom header for responses') [CompletionResult]::new('--print-completions', 'print-completions', [CompletionResultType]::ParameterName, 'Generate completion file for a shell') [CompletionResult]::new('--tls-cert', 'tls-cert', [CompletionResultType]::ParameterName, 'TLS certificate to use') [CompletionResult]::new('--tls-key', 'tls-key', [CompletionResultType]::ParameterName, 'TLS private key to use') [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Be verbose, includes emitting access logs') [CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Be verbose, includes emitting access logs') [CompletionResult]::new('--spa', 'spa', [CompletionResultType]::ParameterName, 'Activate SPA (Single Page Application) mode') [CompletionResult]::new('--random-route', 'random-route', [CompletionResultType]::ParameterName, 'Generate a random 6-hexdigit route') [CompletionResult]::new('-P', 'P', [CompletionResultType]::ParameterName, 'Hide symlinks in listing and prevent them from being followed') [CompletionResult]::new('--no-symlinks', 'no-symlinks', [CompletionResultType]::ParameterName, 'Hide symlinks in listing and prevent them from being followed') [CompletionResult]::new('-H', 'H', [CompletionResultType]::ParameterName, 'Show hidden files') [CompletionResult]::new('--hidden', 'hidden', [CompletionResultType]::ParameterName, 'Show hidden files') [CompletionResult]::new('-q', 'q', [CompletionResultType]::ParameterName, 'Enable QR code display') [CompletionResult]::new('--qrcode', 'qrcode', [CompletionResultType]::ParameterName, 'Enable QR code display') [CompletionResult]::new('-U', 'U', [CompletionResultType]::ParameterName, 'Enable creating directories') [CompletionResult]::new('--mkdir', 'mkdir', [CompletionResultType]::ParameterName, 'Enable creating directories') [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Enable overriding existing files during file upload') [CompletionResult]::new('--overwrite-files', 'overwrite-files', [CompletionResultType]::ParameterName, 'Enable overriding existing files during file upload') [CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Enable uncompressed tar archive generation') [CompletionResult]::new('--enable-tar', 'enable-tar', [CompletionResultType]::ParameterName, 'Enable uncompressed tar archive generation') [CompletionResult]::new('-g', 'g', [CompletionResultType]::ParameterName, 'Enable gz-compressed tar archive generation') [CompletionResult]::new('--enable-tar-gz', 'enable-tar-gz', [CompletionResultType]::ParameterName, 'Enable gz-compressed tar archive generation') [CompletionResult]::new('-z', 'z', [CompletionResultType]::ParameterName, 'Enable zip archive generation') [CompletionResult]::new('--enable-zip', 'enable-zip', [CompletionResultType]::ParameterName, 'Enable zip archive generation') [CompletionResult]::new('-D', 'D', [CompletionResultType]::ParameterName, 'List directories first') [CompletionResult]::new('--dirs-first', 'dirs-first', [CompletionResultType]::ParameterName, 'List directories first') [CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Visualize symlinks in directory listing') [CompletionResult]::new('--show-symlink-info', 'show-symlink-info', [CompletionResultType]::ParameterName, 'Visualize symlinks in directory listing') [CompletionResult]::new('-F', 'F', [CompletionResultType]::ParameterName, 'Hide version footer') [CompletionResult]::new('--hide-version-footer', 'hide-version-footer', [CompletionResultType]::ParameterName, 'Hide version footer') [CompletionResult]::new('--hide-theme-selector', 'hide-theme-selector', [CompletionResultType]::ParameterName, 'Hide theme selector') [CompletionResult]::new('-W', 'W', [CompletionResultType]::ParameterName, 'If enabled, display a wget command to recursively download the current directory') [CompletionResult]::new('--show-wget-footer', 'show-wget-footer', [CompletionResultType]::ParameterName, 'If enabled, display a wget command to recursively download the current directory') [CompletionResult]::new('--print-manpage', 'print-manpage', [CompletionResultType]::ParameterName, 'Generate man page') [CompletionResult]::new('--readme', 'readme', [CompletionResultType]::ParameterName, 'Enable README.md rendering in directories') break } })
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } | Sort-Object -Property ListItemText }
|