src/vs/platform/environment/node/argv.ts

536 LOC · 441 covered · 95 uncovered · 48 ranges · 69 concepts · 11 introducers · 46 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/platform/environment/common/environmentService.ts · 329 LOCcommon/environmentServic…src/vs/platform/environment/node/userDataPath.ts · 106 LOCnode/userDataPath.tsagentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cache hit returns immediately without re-downloading|occurrence=1 · 0 introduced LOCagentSdkDownloader.test|…diskFileSystemProvider.ts ×11 · 79 introduced LOCdiskFileSystemProvider.t…agentSdkDownloader.ts ×3 · 28 introduced LOCagentSdkDownloader.ts ×3diskFileSystemProvider.ts ×20 · 260 introduced LOCdiskFileSystemProvider.t…agentSdkDownloader.ts ×1 · 2 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×1 · 2 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×2 · 20 introduced LOCagentSdkDownloader.ts ×2agentSdkDownloader.ts ×1 · 6 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×2 · 8 introduced LOCagentSdkDownloader.ts ×2agentSdkDownloader.ts ×1 · 5 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×2 · 8 introduced LOCagentSdkDownloader.ts ×2agentSdkDownloader.ts ×5 · 10 introduced LOCagentSdkDownloader.ts ×5agentSdkDownloader.ts ×1 · 3 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×3 · 5 introduced LOCagentSdkDownloader.ts ×3agentSdkDownloader.test|title=AgentSdkDownloader isAvailable: true when product config populated and host has a target|occurrence=1 · 0 introduced LOCagentSdkDownloader.test|…agentSdkDownloader.ts ×1 · 2 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×2 · 3 introduced LOCagentSdkDownloader.ts ×2agentSdkDownloader.ts ×1 · 8 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×1 · 2 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×1 · 2 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×1 · 2 introduced LOCagentSdkDownloader.ts ×1agentSdkDownloader.ts ×2 · 5 introduced LOCagentSdkDownloader.ts ×2ptyHostService.ts ×54 · 735 introduced LOCptyHostService.ts ×54agentHostRequestService.ts ×2 · 7 introduced LOCagentHostRequestService.…agentHostRequestService.ts ×4 · 10 introduced LOCagentHostRequestService.…agentHostRequestService.ts ×6 · 32 introduced LOCagentHostRequestService.…agentHostRequestService.ts ×2 · 4 introduced LOCagentHostRequestService.…agentHostRequestService.ts ×1 · 2 introduced LOCagentHostRequestService.…agentHostRequestService.ts ×1 · 2 introduced LOCagentHostRequestService.…agentHostRequestService.ts ×5 · 8 introduced LOCagentHostRequestService.…agentHostRequestService.ts ×12 · 46 introduced LOCagentHostRequestService.…requestService.ts ×5 · 18 introduced LOCrequestService.ts ×5networkDiagnosticsService.ts ×11 · 83 introduced LOCnetworkDiagnosticsServic…agentHostClientProxyChannel.ts ×4 · 26 introduced LOCagentHostClientProxyChan…agentHostRequestService.ts ×11 · 179 introduced LOCagentHostRequestService.…requestService.ts ×1 · 4 introduced LOCrequestService.ts ×1requestService.ts ×1 · 1 introduced LOCrequestService.ts ×1requestService.ts ×3 · 14 introduced LOCrequestService.ts ×3requestService.ts ×2 · 7 introduced LOCrequestService.ts ×2requestService.ts ×1 · 2 introduced LOCrequestService.ts ×1requestService.ts ×3 · 5 introduced LOCrequestService.ts ×3requestService.ts ×11 · 51 introduced LOCrequestService.ts ×11requestService.ts ×13 · 96 introduced LOCrequestService.ts ×13shellEnv.ts ×2 · 32 introduced LOCshellEnv.ts ×2environmentService.ts ×1 · 7 introduced LOCenvironmentService.ts ×1environmentService.ts ×2 · 4 introduced LOCenvironmentService.ts ×2environmentService.ts ×3 · 12 introduced LOCenvironmentService.ts ×3environmentService.ts ×4 · 22 introduced LOCenvironmentService.ts ×4userDataPath.ts ×5 · 17 introduced LOCuserDataPath.ts ×5userDataPath.test|title=User data path getUserDataPath - --user-data-dir|occurrence=1 · 0 introduced LOCuserDataPath.test|title=…userDataPath.ts ×1 · 2 introduced LOCuserDataPath.ts ×1userDataPath.ts ×1 · 2 introduced LOCuserDataPath.ts ×1userDataPath.ts ×1 · 2 introduced LOCuserDataPath.ts ×1userDataPath.ts ×1 · 7 introduced LOCuserDataPath.ts ×1userDataPath.ts ×1 · 4 introduced LOCuserDataPath.ts ×1userDataPath.ts ×1 · 2 introduced LOCuserDataPath.ts ×1userDataPath.ts ×4 · 21 introduced LOCuserDataPath.ts ×4argv.ts ×7 · 54 introduced LOCargv.ts ×7argv.ts ×2 · 15 introduced LOCargv.ts ×2argv.ts ×1 · 2 introduced LOCargv.ts ×1argv.ts ×3 · 3 introduced LOCargv.ts ×3argv.ts ×5 · 25 introduced LOCargv.ts ×5argv.ts ×1 · 2 introduced LOCargv.ts ×1argv.ts ×13 · 63 introduced LOCargv.ts ×13argv.ts ×1 · 3 introduced LOCargv.ts ×1argv.ts ×5 · 18 introduced LOCargv.ts ×5argvHelper.ts ×1 · 12 introduced LOCargvHelper.ts ×1argvHelper.ts ×6 · 27 introduced LOCargvHelper.ts ×6argv.ts ×9 · 288 introduced LOCargv.ts ×9agentHostRequestService.test|title=AgentHostRequestService does not retry non-idempotent requests|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostRequestService.test|title=AgentHostRequestService does not retry non-idempotent requests|occurrence=1agentHostRequestService.…agentHostRequestService.test|title=AgentHostRequestService forwards cancellation to resolver fetch|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostRequestService.test|title=AgentHostRequestService forwards cancellation to resolver fetch|occurrence=1agentHostRequestService.…agentHostRequestService.test|title=AgentHostRequestService forwards proxy and authorization lookups through the client channel|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostRequestService.test|title=AgentHostRequestService forwards proxy and authorization lookups through the client channel|occurrence=1agentHostRequestService.…agentHostRequestService.test|title=AgentHostRequestService retries idempotent requests on transient errors|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostRequestService.test|title=AgentHostRequestService retries idempotent requests on transient errors|occurrence=1agentHostRequestService.…agentHostRequestService.test|title=AgentHostRequestService uses resolver fetch and streams the response|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostRequestService.test|title=AgentHostRequestService uses resolver fetch and streams the response|occurrence=1agentHostRequestService.…agentHostRequestService.test|title=NetworkDiagnosticsService includes nested proxy response errors|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostRequestService.test|title=NetworkDiagnosticsService includes nested proxy response errors|occurrence=1agentHostRequestService.…agentSdkDownloader.test|title=AgentSdkDownloader isAvailable: false when no env override and no product config|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader isAvailable: false when no env override and no product config|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader isAvailable: true when env override set|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader isAvailable: true when env override set|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader isAvailable: true when product config populated and host has a target|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader isAvailable: true when product config populated and host has a target|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cache dir includes sdkTarget so Universal launches stay separate|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cache dir includes sdkTarget so Universal launches stay separate|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cache hit returns immediately without re-downloading|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cache hit returns immediately without re-downloading|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cache miss → downloads, extracts, writes sentinel|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cache miss → downloads, extracts, writes sentinel|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cancel before download completes cleans up scratch dir|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: cancel before download completes cleans up scratch dir|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: concurrent calls in same process share one download|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: concurrent calls in same process share one download|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: dev override returns the path unchanged|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: dev override returns the path unchanged|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: missing product config and no env override throws actionable error|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: missing product config and no env override throws actionable error|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: rename-loser path returns existing cache when winner already published|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: rename-loser path returns existing cache when winner already published|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: reports monotonic download progress ending at totalBytes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: reports monotonic download progress ending at totalBytes|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: substitutes {sdkTarget} into urlTemplate|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: substitutes {sdkTarget} into urlTemplate|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: urlTemplate with unknown placeholder throws config error|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=AgentSdkDownloader loadSdkRoot: urlTemplate with unknown placeholder throws config error|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=resolveSdkTarget appends -musl on musl Linux iff the package has separate musl SKUs|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=resolveSdkTarget appends -musl on musl Linux iff the package has separate musl SKUs|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=resolveSdkTarget returns <platform>-<arch> for supported (platform, arch)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=resolveSdkTarget returns <platform>-<arch> for supported (platform, arch)|occurrence=1agentSdkDownloader.test|…agentSdkDownloader.test|title=resolveSdkTarget returns undefined for unsupported (platform, arch)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentSdkDownloader.test|title=resolveSdkTarget returns undefined for unsupported (platform, arch)|occurrence=1agentSdkDownloader.test|…argv.test|title=formatOptions Text should display small columns correctly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/argv.test|title=formatOptions Text should display small columns correctly|occurrence=1argv.test|title=formatOp…argv.test|title=formatOptions Text should revert to the condensed view when the terminal is too narrow|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/argv.test|title=formatOptions Text should revert to the condensed view when the terminal is too narrow|occurrence=1argv.test|title=formatOp…argv.test|title=formatOptions Text should wrap|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/argv.test|title=formatOptions Text should wrap|occurrence=1argv.test|title=formatOp…argv.test|title=formatOptions addArg|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/argv.test|title=formatOptions addArg|occurrence=1argv.test|title=formatOp…argv.test|title=formatOptions subcommands|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/argv.test|title=formatOptions subcommands|occurrence=1argv.test|title=formatOp…argv.test|title=parseArgs subcommands|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/argv.test|title=parseArgs subcommands|occurrence=1argv.test|title=parseArg…environmentService.test|title=EnvironmentService careful with boolean file names|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/environmentService.test|title=EnvironmentService careful with boolean file names|occurrence=1environmentService.test|…environmentService.test|title=EnvironmentService parseExtensionHostPort when built|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/environmentService.test|title=EnvironmentService parseExtensionHostPort when built|occurrence=1environmentService.test|…environmentService.test|title=EnvironmentService parseExtensionHostPort when unbuilt|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/environmentService.test|title=EnvironmentService parseExtensionHostPort when unbuilt|occurrence=1environmentService.test|…environmentService.test|title=EnvironmentService userDataDir|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/environmentService.test|title=EnvironmentService userDataDir|occurrence=1environmentService.test|…userDataPath.test|title=User data path getUserDataPath - --user-data-dir|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/userDataPath.test|title=User data path getUserDataPath - --user-data-dir|occurrence=1userDataPath.test|title=…userDataPath.test|title=User data path getUserDataPath - VSCODE_APPDATA|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/userDataPath.test|title=User data path getUserDataPath - VSCODE_APPDATA|occurrence=1userDataPath.test|title=…userDataPath.test|title=User data path getUserDataPath - default|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/userDataPath.test|title=User data path getUserDataPath - default|occurrence=1userDataPath.test|title=…userDataPath.test|title=User data path getUserDataPath - portable mode|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/environment/test/node/userDataPath.test|title=User data path getUserDataPath - portable mode|occurrence=1userDataPath.test|title=…requestService.test|title=Request Service Request cancellation during retry backoff|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service Request cancellation during retry backoff|occurrence=1requestService.test|titl…requestService.test|title=Request Service should NOT retry DELETE requests|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service should NOT retry DELETE requests|occurrence=1requestService.test|titl…requestService.test|title=Request Service should NOT retry PATCH requests|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service should NOT retry PATCH requests|occurrence=1requestService.test|titl…requestService.test|title=Request Service should NOT retry POST requests|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service should NOT retry POST requests|occurrence=1requestService.test|titl…requestService.test|title=Request Service should NOT retry PUT requests|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service should NOT retry PUT requests|occurrence=1requestService.test|titl…requestService.test|title=Request Service should retry GET requests on transient errors|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service should retry GET requests on transient errors|occurrence=1requestService.test|titl…requestService.test|title=Request Service should retry HEAD requests on transient errors|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service should retry HEAD requests on transient errors|occurrence=1requestService.test|titl…requestService.test|title=Request Service should retry OPTIONS requests on transient errors|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/request/test/node/requestService.test|title=Request Service should retry OPTIONS requests on transient errors|occurrence=1requestService.test|titl…ptyHostService.test|title=PtyHostService restartPtyHost disposes listeners registered during pty host startup|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/node/ptyHostService.test|title=PtyHostService restartPtyHost disposes listeners registered during pty host startup|occurrence=1ptyHostService.test|titl…Focused file · src/vs/platform/environment/node/argv.ts · 536 LOCnode/argv.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- argv.ts ×9
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import minimist from 'minimist';
7 > import { isWindows } from '../../../base/common/platform.js';
8 > import { localize } from '../../../nls.js';
9 > import { NativeParsedArgs } from '../common/argv.js';
10 >
11 > /**
12 > * This code is also used by standalone cli's. Avoid adding any other dependencies.
13 > */
14 > const helpCategories = {
15 > o: localize('optionsUpperCase', "Options"),
16 > e: localize('extensionsManagement', "Extensions Management"),
17 > t: localize('troubleshooting', "Troubleshooting"),
18 > m: localize('mcp', "Model Context Protocol")
19 > };
20 >
21 > export interface Option<OptionType> {
22 > type: OptionType;
23 > alias?: string;
24 > deprecates?: string[]; // old deprecated ids
25 > args?: string | string[];
26 > description?: string;
27 > deprecationMessage?: string;
28 > allowEmptyValue?: boolean;
29 > cat?: keyof typeof helpCategories;
30 > global?: boolean;
31 > }
32 >
33 > export interface Subcommand<T> {
34 > type: 'subcommand';
35 > description?: string;
36 > deprecationMessage?: string;
37 > options: OptionDescriptions<Required<T>>;
38 > }
39 >
40 > export type OptionDescriptions<T> = {
41 > [P in keyof T]:
42 > T[P] extends boolean | undefined ? Option<'boolean'> :
43 > T[P] extends string | undefined ? Option<'string'> :
44 > T[P] extends string[] | undefined ? Option<'string[]'> :
45 > Subcommand<T[P]>
46 > };
47 >
48 > export const NATIVE_CLI_COMMANDS = ['tunnel', 'serve-web', 'agent'] as const;
49 >
50 > export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
51 > 'chat': {
52 > type: 'subcommand',
53 > description: 'Pass in a prompt to run in a chat session in the current working directory.',
54 > options: {
55 > '_': { type: 'string[]', description: localize('prompt', "The prompt to use as chat.") },
56 > 'mode': { type: 'string', cat: 'o', alias: 'm', args: 'mode', description: localize('chatMode', "The mode to use for the chat session. Available options: 'ask', 'edit', 'agent', or the identifier of a custom mode. Defaults to 'agent'.") },
57 > 'add-file': { type: 'string[]', cat: 'o', alias: 'a', args: 'path', description: localize('addFile', "Add files as context to the chat session.") },
58 > 'maximize': { type: 'boolean', cat: 'o', description: localize('chatMaximize', "Maximize the chat session view.") },
59 > 'reuse-window': { type: 'boolean', cat: 'o', alias: 'r', description: localize('reuseWindowForChat', "Force to use the last active window for the chat session.") },
60 > 'new-window': { type: 'boolean', cat: 'o', alias: 'n', description: localize('newWindowForChat', "Force to open an empty window for the chat session.") },
61 > 'profile': { type: 'string', 'cat': 'o', args: 'profileName', description: localize('profileName', "Opens the provided folder or workspace with the given profile and associates the profile with the workspace. If the profile does not exist, a new empty one is created.") },
62 > 'help': { type: 'boolean', alias: 'h', description: localize('help', "Print usage.") }
63 > }
64 > },
65 > 'serve-web': {
66 > type: 'subcommand',
67 > description: 'Run a server that displays the editor UI in browsers.',
68 > options: {
69 > 'cli-data-dir': { type: 'string', args: 'dir', description: localize('cliDataDir', "Directory where CLI metadata should be stored.") },
70 > 'disable-telemetry': { type: 'boolean' },
71 > 'telemetry-level': { type: 'string' },
72 > }
73 > },
74 > 'agent': {
75 > type: 'subcommand',
76 > description: 'Start and interact with AI agent hosts.',
77 > options: {
78 > 'cli-data-dir': { type: 'string', args: 'dir', description: localize('cliDataDir', "Directory where CLI metadata should be stored.") },
79 > 'disable-telemetry': { type: 'boolean' },
80 > 'telemetry-level': { type: 'string' },
81 > }
82 > },
83 > 'tunnel': {
84 > type: 'subcommand',
85 > description: 'Make the current machine accessible from vscode.dev or other machines through a secure tunnel.',
86 > options: {
87 > 'cli-data-dir': { type: 'string', args: 'dir', description: localize('cliDataDir', "Directory where CLI metadata should be stored.") },
88 > 'disable-telemetry': { type: 'boolean' },
89 > 'telemetry-level': { type: 'string' },
90 > user: {
91 > type: 'subcommand',
92 > options: {
93 > login: {
94 > type: 'subcommand',
95 > options: {
96 > provider: { type: 'string' },
97 > 'access-token': { type: 'string' }
98 > }
99 > }
100 > }
101 > }
102 > }
103 > },
104 > 'diff': { type: 'boolean', cat: 'o', alias: 'd', args: ['file', 'file'], description: localize('diff', "Compare two files with each other.") },
105 > 'merge': { type: 'boolean', cat: 'o', alias: 'm', args: ['path1', 'path2', 'base', 'result'], description: localize('merge', "Perform a three-way merge by providing paths for two modified versions of a file, the common origin of both modified versions and the output file to save merge results.") },
106 > 'add': { type: 'boolean', cat: 'o', alias: 'a', args: 'folder', description: localize('add', "Add folder(s) to the last active window.") },
107 > 'remove': { type: 'boolean', cat: 'o', args: 'folder', description: localize('remove', "Remove folder(s) from the last active window.") },
108 > 'goto': { type: 'boolean', cat: 'o', alias: 'g', args: 'file:line[:character]', description: localize('goto', "Open a file at the path on the specified line and character position.") },
109 > 'new-window': { type: 'boolean', cat: 'o', alias: 'n', description: localize('newWindow', "Force to open a new window.") },
110 > 'reuse-window': { type: 'boolean', cat: 'o', alias: 'r', description: localize('reuseWindow', "Force to open a file or folder in an already opened window.") },
111 > 'agents': { type: 'boolean', cat: 'o', deprecates: ['sessions'], description: localize('agents', "Opens the agents window.") },
112 > 'wait': { type: 'boolean', cat: 'o', alias: 'w', description: localize('wait', "Wait for the files to be closed before returning.") },
113 > 'waitMarkerFilePath': { type: 'string' },
114 > 'locale': { type: 'string', cat: 'o', args: 'locale', description: localize('locale', "The locale to use (e.g. en-US or zh-TW).") },
115 > 'user-data-dir': { type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") },
116 > 'profile': { type: 'string', 'cat': 'o', args: 'profileName', description: localize('profileName', "Opens the provided folder or workspace with the given profile and associates the profile with the workspace. If the profile does not exist, a new empty one is created.") },
117 > 'help': { type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") },
118 >
119 > 'extensions-dir': { type: 'string', deprecates: ['extensionHomePath'], cat: 'e', args: 'dir', description: localize('extensionHomePath', "Set the root path for extensions.") },
120 > 'extensions-download-dir': { type: 'string' },
121 > 'builtin-extensions-dir': { type: 'string' },
122 > 'shared-data-dir': { type: 'string' },
123 > 'list-extensions': { type: 'boolean', cat: 'e', description: localize('listExtensions', "List the installed extensions.") },
124 > 'agent-plugins-dir': { type: 'string' },
125 > 'agents-user-data-dir': { type: 'string' },
126 > 'agents-extensions-dir': { type: 'string' },
127 > 'show-versions': { type: 'boolean', cat: 'e', description: localize('showVersions', "Show versions of installed extensions, when using --list-extensions.") },
128 > 'category': { type: 'string', allowEmptyValue: true, cat: 'e', description: localize('category', "Filters installed extensions by provided category, when using --list-extensions."), args: 'category' },
129 > 'install-extension': { type: 'string[]', cat: 'e', args: 'ext-id | path', description: localize('installExtension', "Installs or updates an extension. The argument is either an extension id or a path to a VSIX. The identifier of an extension is '${publisher}.${name}'. Use '--force' argument to update to latest version. To install a specific version provide '@${version}'. For example: '[email protected]'.") },
130 > 'pre-release': { type: 'boolean', cat: 'e', description: localize('install prerelease', "Installs the pre-release version of the extension, when using --install-extension") },
131 > 'uninstall-extension': { type: 'string[]', cat: 'e', args: 'ext-id', description: localize('uninstallExtension', "Uninstalls an extension.") },
132 > 'update-extensions': { type: 'boolean', cat: 'e', description: localize('updateExtensions', "Update the installed extensions.") },
133 > 'enable-proposed-api': { type: 'string[]', allowEmptyValue: true, cat: 'e', args: 'ext-id', description: localize('experimentalApis', "Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.") },
134 >
135 > 'add-mcp': { type: 'string[]', cat: 'm', args: 'json', description: localize('addMcp', "Adds a Model Context Protocol server definition to the user profile. Accepts JSON input in the form '{\"name\":\"server-name\",\"command\":...}'") },
136 >
137 > 'version': { type: 'boolean', cat: 't', alias: 'v', description: localize('version', "Print version.") },
138 > 'verbose': { type: 'boolean', cat: 't', global: true, description: localize('verbose', "Print verbose output (implies --wait).") },
139 > 'log': { type: 'string[]', cat: 't', args: 'level', global: true, description: localize('log', "Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'. You can also configure the log level of an extension by passing extension id and log level in the following format: '${publisher}.${name}:${logLevel}'. For example: 'vscode.csharp:trace'. Can receive one or more such entries.") },
140 > 'status': { type: 'boolean', alias: 's', cat: 't', description: localize('status', "Print process usage and diagnostics information.") },
141 > 'prof-startup': { type: 'boolean', cat: 't', description: localize('prof-startup', "Run CPU profiler during startup.") },
142 > 'prof-append-timers': { type: 'string' },
143 > 'prof-duration-markers': { type: 'string[]' },
144 > 'prof-duration-markers-file': { type: 'string' },
145 > 'no-cached-data': { type: 'boolean' },
146 > 'prof-startup-prefix': { type: 'string' },
147 > 'prof-v8-extensions': { type: 'boolean' },
148 > 'disable-extensions': { type: 'boolean', deprecates: ['disableExtensions'], cat: 't', description: localize('disableExtensions', "Disable all installed extensions. This option is not persisted and is effective only when the command opens a new window.") },
149 > 'disable-extension': { type: 'string[]', cat: 't', args: 'ext-id', description: localize('disableExtension', "Disable the provided extension. This option is not persisted and is effective only when the command opens a new window.") },
150 > 'sync': { type: 'string', cat: 't', description: localize('turn sync', "Turn sync on or off."), args: ['on | off'] },
151 >
152 > 'inspect-extensions': { type: 'string', allowEmptyValue: true, deprecates: ['debugPluginHost'], args: 'port', cat: 't', description: localize('inspect-extensions', "Allow debugging and profiling of extensions. Check the developer tools for the connection URI.") },
153 > 'inspect-brk-extensions': { type: 'string', allowEmptyValue: true, deprecates: ['debugBrkPluginHost'], args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") },
154 > 'disable-lcd-text': { type: 'boolean', cat: 't', description: localize('disableLCDText', "Disable LCD font rendering.") },
155 > 'disable-gpu': { type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") },
156 > 'disable-chromium-sandbox': { type: 'boolean', cat: 't', description: localize('disableChromiumSandbox', "Use this option only when there is requirement to launch the application as sudo user on Linux or when running as an elevated user in an applocker environment on Windows.") },
157 > 'sandbox': { type: 'boolean' },
158 > 'locate-shell-integration-path': { type: 'string', cat: 't', args: ['shell'], description: localize('locateShellIntegrationPath', "Print the path to a terminal shell integration script. Allowed values are 'bash', 'pwsh', 'zsh' or 'fish'.") },
159 > 'telemetry': { type: 'boolean', cat: 't', description: localize('telemetry', "Shows all telemetry events which VS code collects.") },
160 >
161 > 'remote': { type: 'string', allowEmptyValue: true },
162 > 'folder-uri': { type: 'string[]', cat: 'o', args: 'uri' },
163 > 'file-uri': { type: 'string[]', cat: 'o', args: 'uri' },
164 >
165 > 'locate-extension': { type: 'string[]' },
166 > 'extensionDevelopmentPath': { type: 'string[]' },
167 > 'extensionDevelopmentKind': { type: 'string[]' },
168 > 'extensionTestsPath': { type: 'string' },
169 > 'extensionEnvironment': { type: 'string' },
170 > 'debugId': { type: 'string' },
171 > 'debugRenderer': { type: 'boolean' },
172 > 'inspect-ptyhost': { type: 'string', allowEmptyValue: true },
173 > 'inspect-brk-ptyhost': { type: 'string', allowEmptyValue: true },
174 > 'inspect-agenthost': { type: 'string', allowEmptyValue: true },
175 > 'inspect-brk-agenthost': { type: 'string', allowEmptyValue: true },
176 > 'inspect-sharedprocess': { type: 'string', allowEmptyValue: true },
177 > 'inspect-brk-sharedprocess': { type: 'string', allowEmptyValue: true },
178 > 'export-default-configuration': { type: 'string' },
179 > 'export-policy-data': { type: 'string', allowEmptyValue: true },
180 > 'export-default-keybindings': { type: 'string', allowEmptyValue: true },
181 > 'install-source': { type: 'string' },
182 > 'enable-smoke-test-driver': { type: 'boolean' },
183 > 'skip-sessions-welcome': { type: 'boolean' },
184 > 'logExtensionHostCommunication': { type: 'boolean' },
185 > 'skip-release-notes': { type: 'boolean' },
186 > 'skip-welcome': { type: 'boolean' },
187 > 'disable-telemetry': { type: 'boolean' },
188 > 'disable-updates': { type: 'boolean' },
189 > 'share-secrets-with-agents-app': { type: 'boolean' },
190 > 'transient': { type: 'boolean', cat: 't', description: localize('transient', "Run with temporary data and extension directories, as if launched for the first time.") },
191 > 'use-inmemory-secretstorage': { type: 'boolean', deprecates: ['disable-keytar'] },
192 > 'password-store': { type: 'string' },
193 > 'disable-workspace-trust': { type: 'boolean' },
194 > 'disable-crash-reporter': { type: 'boolean' },
195 > 'crash-reporter-directory': { type: 'string' },
196 > 'crash-reporter-id': { type: 'string' },
197 > 'skip-add-to-recently-opened': { type: 'boolean' },
198 > 'open-url': { type: 'boolean' },
199 > 'file-write': { type: 'boolean' },
200 > 'file-chmod': { type: 'boolean' },
201 > 'install-builtin-extension': { type: 'string[]' },
202 > 'force': { type: 'boolean' },
203 > 'do-not-sync': { type: 'boolean' },
204 > 'do-not-include-pack-dependencies': { type: 'boolean' },
205 > 'trace': { type: 'boolean' },
206 > 'trace-memory-infra': { type: 'boolean' },
207 > 'trace-category-filter': { type: 'string' },
208 > 'trace-options': { type: 'string' },
209 > 'preserve-env': { type: 'boolean' },
210 > 'force-user-env': { type: 'boolean' },
211 > 'force-disable-user-env': { type: 'boolean' },
212 > 'open-devtools': { type: 'boolean' },
213 > 'disable-gpu-sandbox': { type: 'boolean' },
214 > 'logsPath': { type: 'string' },
215 > '__enable-file-policy': { type: 'boolean' },
216 > 'editSessionId': { type: 'string' },
217 > 'continueOn': { type: 'string' },
218 > 'enable-coi': { type: 'boolean' },
219 > 'unresponsive-sample-interval': { type: 'string' },
220 > 'unresponsive-sample-period': { type: 'string' },
221 > 'enable-rdp-display-tracking': { type: 'boolean' },
222 > 'disable-layout-restore': { type: 'boolean' },
223 > 'disable-experiments': { type: 'boolean' },
224 >
225 > // chromium flags
226 > 'no-proxy-server': { type: 'boolean' },
227 > // Minimist incorrectly parses keys that start with `--no`
228 > // https://github.com/substack/minimist/blob/aeb3e27dae0412de5c0494e9563a5f10c82cc7a9/index.js#L118-L121
229 > // If --no-sandbox is passed via cli wrapper it will be treated as --sandbox which is incorrect, we use
230 > // the alias here to make sure --no-sandbox is always respected.
231 > // For https://github.com/microsoft/vscode/issues/128279
232 > 'no-sandbox': { type: 'boolean', alias: 'sandbox' },
233 > 'proxy-server': { type: 'string' },
234 > 'proxy-bypass-list': { type: 'string' },
235 > 'proxy-pac-url': { type: 'string' },
236 > 'js-flags': { type: 'string' }, // chrome js flags
237 > 'inspect': { type: 'string', allowEmptyValue: true },
238 > 'inspect-brk': { type: 'string', allowEmptyValue: true },
239 > 'nolazy': { type: 'boolean' }, // node inspect
240 > 'force-device-scale-factor': { type: 'string' },
241 > 'force-renderer-accessibility': { type: 'boolean' },
242 > 'ignore-certificate-errors': { type: 'boolean' },
243 > 'allow-insecure-localhost': { type: 'boolean' },
244 > 'log-net-log': { type: 'string' },
245 > 'vmodule': { type: 'string' },
246 > '_urls': { type: 'string[]' },
247 > 'disable-dev-shm-usage': { type: 'boolean' },
248 > 'profile-temp': { type: 'boolean' },
249 > 'ozone-platform': { type: 'string' },
250 > 'enable-tracing': { type: 'string' },
251 > 'trace-startup-format': { type: 'string' },
252 > 'trace-startup-file': { type: 'string' },
253 > 'trace-startup-duration': { type: 'string' },
254 > 'xdg-portal-required-version': { type: 'string' },
255 >
256 > _: { type: 'string[]' } // main arguments
257 > };
258 >
259 > export interface ErrorReporter {
260 > onUnknownOption(id: string): void;
261 > onMultipleValues(id: string, usedValue: string): void;
262 > onEmptyValue(id: string): void;
263 > onDeprecatedOption(deprecatedId: string, message: string): void;
264 >
265 > getSubcommandReporter?(command: string): ErrorReporter;
266 > }
267 >
268 > const ignoringReporter = {
269 > onUnknownOption: () => { },
270 > onMultipleValues: () => { },
271 > onEmptyValue: () => { },
272 > onDeprecatedOption: () => { }
273 > };
274 >
275 > export function parseArgs<T>(args: string[], options: OptionDescriptions<T>, errorReporter: ErrorReporter = ignoringReporter): T {
276 > // Find the first non-option arg, which also isn't the value for a previous `--flag` argv.ts ×13
277 > const firstPossibleCommand = args.find((a, i) => a.length > 0 && a[0] !== '-' && options.hasOwnProperty(a) && options[a as T].type === 'subcommand');
278 >
279 > const alias: { [key: string]: string } = {};
280 > const stringOptions: string[] = ['_'];
281 > const booleanOptions: string[] = [];
282 > const globalOptions: Record<string, Option<'boolean'> | Option<'string'> | Option<'string[]'>> = {};
283 > let command: Subcommand<Record<string, unknown>> | undefined = undefined;
284 > for (const optionId in options) {
285 > const o = options[optionId];
286 > if (o.type === 'subcommand') {
287 > if (optionId === firstPossibleCommand) {
288 > command = o; argv.ts ×2
289 > }
290 > } else { argv.ts ×13
291 > if (o.alias) {
292 > alias[optionId] = o.alias; argv.ts ×7
293 > }
294 > argv.ts ×13
295 > if (o.type === 'string' || o.type === 'string[]') {
296 > stringOptions.push(optionId);
297 > if (o.deprecates) {
298 > stringOptions.push(...o.deprecates); argv.ts ×7
299 > }
300 > } else if (o.type === 'boolean') { argv.ts ×13
301 > booleanOptions.push(optionId);
302 > if (o.deprecates) {
303 > booleanOptions.push(...o.deprecates); argv.ts ×7
304 > }
305 > } argv.ts ×13
306 > if (o.global) {
307 > globalOptions[optionId] = o;
308 > }
309 > }
310 > }
311 > if (command && firstPossibleCommand) {
312 > const options: Record<string, Option<'boolean'> | Option<'string'> | Option<'string[]'> | Subcommand<Record<string, unknown>>> = globalOptions; argv.ts ×2
313 > for (const optionId in command.options) {
314 > options[optionId] = command.options[optionId];
315 > }
316 > const newArgs = args.filter(a => a !== firstPossibleCommand);
317 > const reporter = errorReporter.getSubcommandReporter ? errorReporter.getSubcommandReporter(firstPossibleCommand) : undefined;
318 > const subcommandOptions = parseArgs(newArgs, options as OptionDescriptions<Record<string, unknown>>, reporter);
319 > // eslint-disable-next-line local/code-no-dangerous-type-assertions
320 > return <T>{
321 > [firstPossibleCommand]: subcommandOptions,
322 > _: []
323 > };
324 > }
325 > argv.ts ×13
326 >
327 > // remove aliases to avoid confusion
328 > const parsedArgs = minimist(args, { string: stringOptions, boolean: booleanOptions, alias });
329 >
330 > const cleanedArgs: Record<string, unknown> = {};
331 > const remainingArgs: Record<string, unknown> = parsedArgs;
332 >
333 > // https://github.com/microsoft/vscode/issues/58177, https://github.com/microsoft/vscode/issues/106617
334 > cleanedArgs._ = parsedArgs._.map(arg => String(arg)).filter(arg => arg.length > 0);
335 >
336 > delete remainingArgs._;
337 >
338 > for (const optionId in options) {
339 > const o = options[optionId];
340 > if (o.type === 'subcommand') {
341 > continue; argv.ts ×7
342 > }
343 > if (o.alias) { argv.ts ×13
344 > delete remainingArgs[o.alias]; argv.ts ×7
345 > }
346 > argv.ts ×13
347 > let val = remainingArgs[optionId];
348 > if (o.deprecates) {
349 > for (const deprecatedId of o.deprecates) { argv.ts ×7
350 > if (remainingArgs.hasOwnProperty(deprecatedId)) {
351 > if (!val) {
352 > val = remainingArgs[deprecatedId];
353 > if (val) {
354 > errorReporter.onDeprecatedOption(deprecatedId, o.deprecationMessage || localize('deprecated.useInstead', 'Use {0} instead.', optionId)); environmentService.ts ×3
355 > }
356 > } argv.ts ×7
357 > delete remainingArgs[deprecatedId];
358 > }
359 > }
360 > }
361 > argv.ts ×13
362 > if (typeof val !== 'undefined') {
363 > if (o.type === 'string[]') {
364 if (!Array.isArray(val)) {
365 val = [val];
366 }
367 if (!o.allowEmptyValue) {
368 const sanitized = (val as string[]).filter((v: string) => v.length > 0);
369 if (sanitized.length !== (val as string[]).length) {
370 errorReporter.onEmptyValue(optionId);
371 val = sanitized.length > 0 ? sanitized : undefined;
372 }
373 }
374 > } else if (o.type === 'string') { argv.ts ×13
375 > if (Array.isArray(val)) { argv.ts ×3
376 val = val.pop(); // take the last
377 errorReporter.onMultipleValues(optionId, val as string);
378 > } else if (!val && !o.allowEmptyValue) { argv.ts ×3
379 errorReporter.onEmptyValue(optionId);
380 val = undefined;
381 }
382 > } argv.ts ×3
383 > cleanedArgs[optionId] = val; argv.ts ×13
384 >
385 > if (o.deprecationMessage) {
386 errorReporter.onDeprecatedOption(optionId, o.deprecationMessage);
387 }
388 > } argv.ts ×13
389 > delete remainingArgs[optionId];
390 > }
391 >
392 > for (const key in remainingArgs) {
393 > errorReporter.onUnknownOption(key); argv.ts ×1
394 > }
395 > argv.ts ×13
396 > return cleanedArgs as T;
397 > }
398 > argv.ts ×9
399 > function formatUsage(optionId: string, option: Option<'boolean'> | Option<'string'> | Option<'string[]'>) { argv.ts ×5
400 > let args = '';
401 > if (option.args) {
402 if (Array.isArray(option.args)) {
403 args = ` <${option.args.join('> <')}>`;
404 } else {
405 args = ` <${option.args}>`;
406 }
407 }
408 > if (option.alias) { argv.ts ×5
409 return `-${option.alias} --${optionId}${args}`;
410 }
411 > return `--${optionId}${args}`; argv.ts ×5
412 > }
413 > argv.ts ×9
414 > // exported only for testing
415 > export function formatOptions(options: OptionDescriptions<unknown> | Record<string, Option<'boolean'> | Option<'string'> | Option<'string[]'>>, columns: number): string[] {
416 > const usageTexts: [string, string][] = []; argv.ts ×5
417 > for (const optionId in options) {
418 > const o = options[optionId as keyof typeof options] as Option<'boolean'> | Option<'string'> | Option<'string[]'>;
419 > const usageText = formatUsage(optionId, o);
420 > usageTexts.push([usageText, o.description!]);
421 > }
422 > return formatUsageTexts(usageTexts, columns);
423 > }
424 > argv.ts ×9
425 > function formatUsageTexts(usageTexts: [string, string][], columns: number) { argv.ts ×5
426 > const maxLength = usageTexts.reduce((previous, e) => Math.max(previous, e[0].length), 12);
427 > const argLength = maxLength + 2/*left padding*/ + 1/*right padding*/;
428 > if (columns - argLength < 25) {
429 > // Use a condensed version on narrow terminals argv.ts ×1
430 > return usageTexts.reduce<string[]>((r, ut) => r.concat([` ${ut[0]}`, ` ${ut[1]}`]), []);
431 > }
432 > const descriptionColumns = columns - argLength - 1; argv.ts ×5
433 > const result: string[] = [];
434 > for (const ut of usageTexts) {
435 > const usage = ut[0];
436 > const wrappedDescription = wrapText(ut[1], descriptionColumns);
437 > const keyPadding = indent(argLength - usage.length - 2/*left padding*/);
438 > result.push(' ' + usage + keyPadding + wrappedDescription[0]);
439 > for (let i = 1; i < wrappedDescription.length; i++) {
440 > result.push(indent(argLength) + wrappedDescription[i]); argv.ts ×1
441 > }
442 > } argv.ts ×5
443 > return result;
444 > }
445 > argv.ts ×9
446 > function indent(count: number): string { argv.ts ×5
447 > return ' '.repeat(count);
448 > }
449 > argv.ts ×9
450 > function wrapText(text: string, columns: number): string[] { argv.ts ×5
451 > const lines: string[] = [];
452 > while (text.length) {
453 > let index = text.length < columns ? text.length : text.lastIndexOf(' ', columns);
454 > if (index === 0) {
455 index = columns;
456 }
457 > const line = text.slice(0, index).trim(); argv.ts ×5
458 > text = text.slice(index).trimStart();
459 > lines.push(line);
460 > }
461 > return lines;
462 > }
463 > argv.ts ×9
464 > export function buildHelpMessage(productName: string, executableName: string, version: string, options: OptionDescriptions<unknown> | Record<string, Option<'boolean'> | Option<'string'> | Option<'string[]'> | Subcommand<Record<string, unknown>>>, capabilities?: { noPipe?: boolean; noInputFiles?: boolean; isChat?: boolean }): string {
465 const columns = (process.stdout).isTTY && (process.stdout).columns || 80;
466 const inputFiles = capabilities?.noInputFiles ? '' : capabilities?.isChat ? ` [${localize('cliPrompt', 'prompt')}]` : ` [${localize('paths', 'paths')}...]`;
467 const subcommand = capabilities?.isChat ? ' chat' : '';
468
469 const help = [`${productName} ${version}`];
470 help.push('');
471 help.push(`${localize('usage', "Usage")}: ${executableName}${subcommand} [${localize('options', "options")}]${inputFiles}`);
472 help.push('');
473 if (capabilities?.noPipe !== true) {
474 help.push(buildStdinMessage(executableName, capabilities?.isChat));
475 help.push('');
476 }
477 const optionsByCategory: { [P in keyof typeof helpCategories]?: Record<string, Option<'boolean'> | Option<'string'> | Option<'string[]'>> } = {};
478 const subcommands: { command: string; description: string }[] = [];
479 for (const optionId in options) {
480 const o = options[optionId as keyof typeof options] as Option<'boolean'> | Option<'string'> | Option<'string[]'> | Subcommand<Record<string, unknown>>;
481 if (o.type === 'subcommand') {
482 if (o.description) {
483 subcommands.push({ command: optionId, description: o.description });
484 }
485 } else if (o.description && o.cat) {
486 const cat = o.cat;
487 let optionsByCat = optionsByCategory[cat];
488 if (!optionsByCat) {
489 optionsByCategory[cat] = optionsByCat = {};
490 }
491 optionsByCat[optionId] = o;
492 }
493 }
494
495 for (const helpCategoryKey in optionsByCategory) {
496 const key = <keyof typeof helpCategories>helpCategoryKey;
497
498 const categoryOptions = optionsByCategory[key];
499 if (categoryOptions) {
500 help.push(helpCategories[key]);
501 help.push(...formatOptions(categoryOptions, columns));
502 help.push('');
503 }
504 }
505
506 if (subcommands.length) {
507 help.push(localize('subcommands', "Subcommands"));
508 help.push(...formatUsageTexts(subcommands.map(s => [s.command, s.description]), columns));
509 help.push('');
510 }
511
512 return help.join('\n');
513 }
514 > argv.ts ×9
515 > export function buildStdinMessage(executableName: string, isChat?: boolean): string {
516 let example: string;
517 if (isWindows) {
518 if (isChat) {
519 example = `echo Hello World | ${executableName} chat <prompt> -`;
520 } else {
521 example = `echo Hello World | ${executableName} -`;
522 }
523 } else {
524 if (isChat) {
525 example = `ps aux | grep code | ${executableName} chat <prompt> -`;
526 } else {
527 example = `ps aux | grep code | ${executableName} -`;
528 }
529 }
530
531 return localize('stdinUsage', "To read from stdin, append '-' (e.g. '{0}')", example);
532 }
533 > argv.ts ×9
534 > export function buildVersionMessage(version: string | undefined, commit: string | undefined): string {
535 return `${version || localize('unknownVersion', "Unknown version")}\n${commit || localize('unknownCommit', "Unknown commit")}\n${process.arch}`;
536 }