diff --git a/extensions/terminal-suggest/src/completions/code-tunnel-insiders.ts b/extensions/terminal-suggest/src/completions/code-tunnel-insiders.ts index e1ca18bc10e..dd54a2439ec 100644 --- a/extensions/terminal-suggest/src/completions/code-tunnel-insiders.ts +++ b/extensions/terminal-suggest/src/completions/code-tunnel-insiders.ts @@ -2,18 +2,21 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { commonOptions, extensionManagementOptions, troubleshootingOptions, tunnelOptions } from './code'; -import codeTunnelCompletionSpec from './code-tunnel'; +import { commonOptions, extensionManagementOptions, troubleshootingOptions, globalTunnelOptions, codeTunnelSubcommands, extTunnelSubcommand, codeTunnelOptions } from './code'; +import codeTunnelCompletionSpec, { codeTunnelSpecOptions } from './code-tunnel'; const codeTunnelInsidersCompletionSpec: Fig.Spec = { ...codeTunnelCompletionSpec, name: 'code-tunnel-insiders', description: 'Create a tunnel that\'s accessible on vscode.dev from anywhere, with insider features.', + subcommands: [...codeTunnelSubcommands, extTunnelSubcommand], options: [ ...commonOptions, ...extensionManagementOptions('code-tunnel-insiders'), ...troubleshootingOptions('code-tunnel-insiders'), - ...tunnelOptions + ...globalTunnelOptions, + ...codeTunnelOptions, + ...codeTunnelSpecOptions ] }; diff --git a/extensions/terminal-suggest/src/completions/code-tunnel.ts b/extensions/terminal-suggest/src/completions/code-tunnel.ts index d91e6bc9c4d..a53edd52ef2 100644 --- a/extensions/terminal-suggest/src/completions/code-tunnel.ts +++ b/extensions/terminal-suggest/src/completions/code-tunnel.ts @@ -2,18 +2,92 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import code, { codeTunnelSubcommands, commonOptions, extensionManagementOptions, troubleshootingOptions, tunnelOptions } from './code'; +import code, { codeTunnelSubcommands, commonOptions, extensionManagementOptions, troubleshootingOptions, globalTunnelOptions, extTunnelSubcommand, codeTunnelOptions } from './code'; + + +export const codeTunnelSpecOptions: Fig.Option[] = [ + { + name: '--cli-data-dir', + description: 'Directory where CLI metadata should be stored', + isRepeatable: true, + args: { + name: 'cli_data_dir', + isOptional: true, + }, + }, + { + name: '--log-to-file', + description: 'Log to a file in addition to stdout. Used when running as a service', + hidden: true, + isRepeatable: true, + args: { + name: 'log_to_file', + isOptional: true, + template: 'filepaths', + }, + }, + { + name: '--log', + description: 'Log level to use', + isRepeatable: true, + args: { + name: 'log', + isOptional: true, + suggestions: [ + 'trace', + 'debug', + 'info', + 'warn', + 'error', + 'critical', + 'off', + ], + }, + }, + { + name: '--telemetry-level', + description: 'Sets the initial telemetry level', + hidden: true, + isRepeatable: true, + args: { + name: 'telemetry_level', + isOptional: true, + suggestions: [ + 'off', + 'crash', + 'error', + 'all', + ], + }, + }, + { + name: '--verbose', + description: 'Print verbose output (implies --wait)', + }, + { + name: '--disable-telemetry', + description: 'Disable telemetry for the current command, even if it was previously accepted as part of the license prompt or specified in \'--telemetry-level\'', + }, + { + name: ['-h', '--help'], + description: 'Print help', + }, +]; const codeTunnelCompletionSpec: Fig.Spec = { ...code, name: 'code-tunnel', description: 'Create a tunnel that\'s accessible on vscode.dev from anywhere.', - subcommands: codeTunnelSubcommands, + subcommands: [ + ...codeTunnelSubcommands, + extTunnelSubcommand + ], options: [ ...commonOptions, ...extensionManagementOptions('code-tunnel'), ...troubleshootingOptions('code-tunnel'), - ...tunnelOptions + ...globalTunnelOptions, + ...codeTunnelOptions ] }; diff --git a/extensions/terminal-suggest/src/completions/code.ts b/extensions/terminal-suggest/src/completions/code.ts index 20bb2c13660..1ae5957ac61 100644 --- a/extensions/terminal-suggest/src/completions/code.ts +++ b/extensions/terminal-suggest/src/completions/code.ts @@ -154,76 +154,6 @@ export const commonOptions: Fig.Option[] = [ } ]; -export const commonCLIOptions: Fig.Option[] = [ - { - name: '--cli-data-dir', - description: 'Directory where CLI metadata should be stored', - isRepeatable: true, - args: { - name: 'cli_data_dir', - isOptional: true, - }, - }, - { - name: '--log-to-file', - description: 'Log to a file in addition to stdout. Used when running as a service', - hidden: true, - isRepeatable: true, - args: { - name: 'log_to_file', - isOptional: true, - template: 'filepaths', - }, - }, - { - name: '--log', - description: 'Log level to use', - isRepeatable: true, - args: { - name: 'log', - isOptional: true, - suggestions: [ - 'trace', - 'debug', - 'info', - 'warn', - 'error', - 'critical', - 'off', - ], - }, - }, - { - name: '--telemetry-level', - description: 'Sets the initial telemetry level', - hidden: true, - isRepeatable: true, - args: { - name: 'telemetry_level', - isOptional: true, - suggestions: [ - 'off', - 'crash', - 'error', - 'all', - ], - }, - }, - { - name: '--verbose', - description: 'Print verbose output (implies --wait)', - }, - { - name: '--disable-telemetry', - description: 'Disable telemetry for the current command, even if it was previously accepted as part of the license prompt or specified in \'--telemetry-level\'', - }, - { - name: ['-h', '--help'], - description: 'Print help', - }, -]; - - export const extensionManagementOptions = (cliName: string): Fig.Option[] => [ { name: '--extensions-dir', @@ -446,7 +376,14 @@ export const commonAuthOptions: Fig.Option[] = [ } ]; -export const tunnelOptions: Fig.Option[] = [ +export const tunnelHelpOptions: Fig.Option[] = [ + { + name: ['-h', '--help'], + description: 'Print help', + }, +]; + +export const globalTunnelOptions: Fig.Option[] = [ { name: '--cli-data-dir', description: 'Directory where CLI metadata should be stored', @@ -455,31 +392,127 @@ export const tunnelOptions: Fig.Option[] = [ }, }, { - name: '--log-to-file', - description: 'Log to a file in addition to stdout. Used when running as a service', - hidden: true, - args: { - name: 'log_to_file', - template: 'filepaths', - }, + name: '--verbose', + description: 'Print verbose output (implies --wait)', }, - { - name: '--telemetry-level', - description: 'Sets the initial telemetry level', - hidden: true, + name: '--log', + description: 'Log level to use', + isRepeatable: true, args: { - name: 'telemetry_level', + name: 'log', + isOptional: true, suggestions: [ - 'off', - 'crash', + 'trace', + 'debug', + 'info', + 'warn', 'error', - 'all', + 'critical', + 'off', ], }, - } + }, ]; + +export const codeTunnelOptions = [ + { + name: '--extensions-dir', + description: 'Set the root path for extensions', + isRepeatable: true, + args: { + name: 'extensions_dir', + isOptional: true, + }, + }, + { + name: '--user-data-dir', + description: 'Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of the editor', + isRepeatable: true, + args: { + name: 'user_data_dir', + isOptional: true, + }, + }, + { + name: '--use-version', + description: 'Sets the editor version to use for this command. The preferred version can be persisted with `code version use `. Can be \'stable\', \'insiders\', a version number, or an absolute path to an existing install', + isRepeatable: true, + args: { + name: 'use_version', + isOptional: true, + }, + }, +]; + +export const extTunnelSubcommand = { + name: 'ext', + description: 'Manage editor extensions', + subcommands: [ + { + name: 'list', + description: 'List installed extensions', + options: [...globalTunnelOptions, ...tunnelHelpOptions, + { + name: '--category', + description: 'Filters installed extensions by provided category, when using --list-extensions', + isRepeatable: true, + args: { + name: 'category', + isOptional: true, + }, + }, + { + name: '--show-versions', + description: 'Show versions of installed extensions, when using --list-extensions', + }, + ] + }, + { + name: 'install', + description: 'Install an extension', + options: [...globalTunnelOptions, ...tunnelHelpOptions, + { + name: '--pre-release', + description: 'Installs the pre-release version of the extension', + }, + { + name: '--donot-include-pack-and-dependencies', + description: `Don't include installing pack and dependencies of the extension`, + }, + { + name: '--force', + description: `Update to the latest version of the extension if it's already installed`, + }, + ], + args: { + name: 'ext-id | id', + isVariadic: true, + isOptional: true, + }, + }, + { + name: 'uninstall', + description: 'Uninstall an extension', + options: [...globalTunnelOptions, ...tunnelHelpOptions], + args: { + name: 'ext-id | id', + isVariadic: true, + isOptional: true, + }, + }, + { + name: 'update', + description: 'Update the installed extensions', + options: [...globalTunnelOptions, ...tunnelHelpOptions] + }, + ], + ...globalTunnelOptions, + ...codeTunnelOptions +}; + + export const codeTunnelSubcommands = [ { name: 'tunnel', @@ -488,27 +521,27 @@ export const codeTunnelSubcommands = [ { name: 'prune', description: 'Delete all servers which are currently not running', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'kill', description: 'Stops any running tunnel on the system', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'restart', description: 'Restarts any running tunnel on the system', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'status', description: 'Gets whether there is a tunnel running on the current machine', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'rename', description: 'Rename the name of this machine associated with port forwarding service', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], args: { name: 'name', }, @@ -516,12 +549,12 @@ export const codeTunnelSubcommands = [ { name: 'status', description: 'Print process usage and diagnostics information', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'unregister', description: 'Remove this machine\'s association with the port forwarding service', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'user', @@ -529,17 +562,17 @@ export const codeTunnelSubcommands = [ { name: 'login', description: 'Log in to port forwarding service', - options: [...commonAuthOptions, ...commonCLIOptions], + options: [...globalTunnelOptions, ...tunnelHelpOptions, ...commonAuthOptions], }, { name: 'logout', description: 'Log out of port forwarding service', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'show', description: 'Show the account that\'s logged into port forwarding service', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'help', @@ -550,10 +583,8 @@ export const codeTunnelSubcommands = [ { name: 'show', description: 'Show the account that\'s logged into port forwarding service' }, { name: 'help', description: 'Print this message or the help of the given subcommand(s)' }, ], - options: commonCLIOptions, }, ], - options: commonCLIOptions, }, { name: 'service', @@ -576,18 +607,18 @@ export const codeTunnelSubcommands = [ name: '--accept-server-license-terms', description: 'If set, the user accepts the server license terms and the server will be started without a user prompt', }, - ...commonCLIOptions, + ...globalTunnelOptions, ...tunnelHelpOptions ], }, { name: 'uninstall', description: 'Uninstalls and stops the tunnel service', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'log', description: 'Shows logs for the running service', - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'help', @@ -598,10 +629,9 @@ export const codeTunnelSubcommands = [ { name: 'log', description: 'Shows logs for the running service' }, { name: 'help', description: 'Print this message or the help of the given subcommand(s)' }, ], - options: commonCLIOptions }, ], - options: commonCLIOptions, + options: [...globalTunnelOptions, ...tunnelHelpOptions], }, { name: 'help', @@ -634,27 +664,105 @@ export const codeTunnelSubcommands = [ ], }, ], - options: tunnelOptions - }, - { - name: 'ext', - description: 'Manage editor extensions', - subcommands: [ + options: [ { - name: 'list', - description: 'List installed extensions', + name: '--install-extension', + description: 'Requests that extensions be preloaded and installed on connecting servers', + isRepeatable: true, + args: { + name: 'install_extension', + isOptional: true, + }, }, { - name: 'install', - description: 'Install an extension', + name: '--server-data-dir', + description: 'Specifies the directory that server data is kept in', + isRepeatable: true, + args: { + name: 'server_data_dir', + isOptional: true, + }, }, { - name: 'uninstall', - description: 'Uninstall an extension', + name: '--extensions-dir', + description: 'Set the root path for extensions', + isRepeatable: true, + args: { + name: 'extensions_dir', + isOptional: true, + }, }, { - name: 'update', - description: 'Update the installed extensions', + name: '--user-data-dir', + description: 'Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of the editor', + isRepeatable: true, + args: { + name: 'user_data_dir', + isOptional: true, + }, + }, + { + name: '--use-version', + description: 'Sets the editor version to use for this command. The preferred version can be persisted with `code version use `. Can be \'stable\', \'insiders\', a version number, or an absolute path to an existing install', + isRepeatable: true, + args: { + name: 'use_version', + isOptional: true, + }, + }, + { + name: '--random-name', + description: 'Randomly name machine for port forwarding service', + }, + { + name: '--no-sleep', + description: 'Prevents the machine going to sleep while this command runs', + }, + { + name: '--accept-server-license-terms', + description: 'If set, the user accepts the server license terms and the server will be started without a user prompt', + }, + { + name: '--name', + description: 'Sets the machine name for port forwarding service', + isRepeatable: true, + args: { + name: 'name', + isOptional: true, + }, + }, + { + name: ['-h', '--help'], + description: 'Print help', + }, + { + name: '--log', + description: 'Log level to use', + isRepeatable: true, + args: { + name: 'log', + isOptional: true, + suggestions: [ + 'trace', + 'debug', + 'info', + 'warn', + 'error', + 'critical', + 'off', + ], + }, + }, + { + name: '--verbose', + description: 'Print verbose output (implies --wait)', + }, + { + name: '--cli-data-dir', + description: 'Directory where CLI metadata should be stored', + args: { + name: 'cli_data_dir', + }, }, ], }, @@ -665,7 +773,7 @@ export const codeTunnelSubcommands = [ { name: 'version', description: `Changes the version of the editor you're using`, - options: tunnelOptions + options: globalTunnelOptions }, { name: 'serve-web', @@ -741,7 +849,7 @@ export const codeTunnelSubcommands = [ name: '--accept-server-license-terms', description: 'If set, the user accepts the server license terms and the server will be started without a user prompt', }, - ...commonCLIOptions, + ...globalTunnelOptions, ...tunnelHelpOptions, ] }, { @@ -813,28 +921,7 @@ export const codeTunnelSubcommands = [ } ], }, - { - name: 'ext', - description: 'Manage editor extensions', - subcommands: [ - { - name: 'list', - description: 'List installed extensions', - }, - { - name: 'install', - description: 'Install an extension', - }, - { - name: 'uninstall', - description: 'Uninstall an extension', - }, - { - name: 'update', - description: 'Update the installed extensions', - }, - ], - }, + extTunnelSubcommand, { name: 'status', description: 'Print process usage and diagnostics information', diff --git a/extensions/terminal-suggest/src/test/completions/code.test.ts b/extensions/terminal-suggest/src/test/completions/code.test.ts index 3ca8ee8f837..b327e3e438e 100644 --- a/extensions/terminal-suggest/src/test/completions/code.test.ts +++ b/extensions/terminal-suggest/src/test/completions/code.test.ts @@ -55,7 +55,6 @@ export const codeSpecOptionsAndSubcommands = [ '--wait', 'tunnel', 'serve-web', - 'ext', 'help', 'status', 'version'