mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -15,10 +15,17 @@ import { MIN_MAX_MEMORY_SIZE_MB } from 'vs/platform/files/common/files';
|
||||
|
||||
const options: minimist.Opts = {
|
||||
string: [
|
||||
// {{SQL CARBON EDIT}}
|
||||
'database',
|
||||
'server',
|
||||
'user',
|
||||
// {{SQL CARBON EDIT}} - End
|
||||
'locale',
|
||||
'user-data-dir',
|
||||
'extensions-dir',
|
||||
'folder-uri',
|
||||
'file-uri',
|
||||
'remote',
|
||||
'extensionDevelopmentPath',
|
||||
'extensionTestsPath',
|
||||
'install-extension',
|
||||
@@ -34,6 +41,9 @@ const options: minimist.Opts = {
|
||||
'install-source',
|
||||
'upload-logs',
|
||||
'driver',
|
||||
'trace-category-filter',
|
||||
'trace-options',
|
||||
'_',
|
||||
// {{SQL CARBON EDIT}}
|
||||
'database',
|
||||
'server',
|
||||
@@ -42,6 +52,10 @@ const options: minimist.Opts = {
|
||||
// {{SQL CARBON EDIT}}
|
||||
],
|
||||
boolean: [
|
||||
// {{SQL CARBON EDIT}}
|
||||
'aad',
|
||||
'integrated',
|
||||
// {{SQL CARBON EDIT}} - End
|
||||
'help',
|
||||
'version',
|
||||
'wait',
|
||||
@@ -73,10 +87,7 @@ const options: minimist.Opts = {
|
||||
'file-write',
|
||||
'file-chmod',
|
||||
'driver-verbose',
|
||||
// {{SQL CARBON EDIT}}
|
||||
'aad',
|
||||
'integrated',
|
||||
// {{SQL CARBON EDIT}}
|
||||
'trace'
|
||||
],
|
||||
alias: {
|
||||
add: 'a',
|
||||
@@ -117,7 +128,7 @@ function validate(args: ParsedArgs): ParsedArgs {
|
||||
return args;
|
||||
}
|
||||
|
||||
function stripAppPath(argv: string[]): string[] {
|
||||
function stripAppPath(argv: string[]): string[] | undefined {
|
||||
const index = firstIndex(argv, a => !/^-/.test(a));
|
||||
|
||||
if (index > -1) {
|
||||
@@ -134,7 +145,7 @@ export function parseMainProcessArgv(processArgv: string[]): ParsedArgs {
|
||||
|
||||
// If dev, remove the first non-option argument: it's the app location
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
args = stripAppPath(args);
|
||||
args = stripAppPath(args) || [];
|
||||
}
|
||||
|
||||
return validate(parseArgs(args));
|
||||
@@ -147,7 +158,7 @@ export function parseCLIProcessArgv(processArgv: string[]): ParsedArgs {
|
||||
let [, , ...args] = processArgv;
|
||||
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
args = stripAppPath(args);
|
||||
args = stripAppPath(args) || [];
|
||||
}
|
||||
|
||||
return validate(parseArgs(args));
|
||||
@@ -162,7 +173,6 @@ export function parseArgs(args: string[]): ParsedArgs {
|
||||
|
||||
const optionsHelp: { [name: string]: string; } = {
|
||||
'-d, --diff <file> <file>': localize('diff', "Compare two files with each other."),
|
||||
'--folder-uri <uri>': localize('folder uri', "Opens a window with given folder uri(s)"),
|
||||
'-a, --add <dir>': localize('add', "Add folder(s) to the last active window."),
|
||||
'-g, --goto <file:line[:character]>': localize('goto', "Open a file at the path on the specified line and character position."),
|
||||
'-n, --new-window': localize('newWindow', "Force to open a new window."),
|
||||
@@ -178,8 +188,8 @@ const extensionsHelp: { [name: string]: string; } = {
|
||||
'--extensions-dir <dir>': localize('extensionHomePath', "Set the root path for extensions."),
|
||||
'--list-extensions': localize('listExtensions', "List the installed extensions."),
|
||||
'--show-versions': localize('showVersions', "Show versions of installed extensions, when using --list-extension."),
|
||||
'--install-extension (<extension-id> | <extension-vsix-path>)': localize('installExtension', "Installs an extension."),
|
||||
'--uninstall-extension (<extension-id> | <extension-vsix-path>)': localize('uninstallExtension', "Uninstalls an extension."),
|
||||
'--install-extension (<extension-id> | <extension-vsix-path>)': localize('installExtension', "Installs or updates the extension. Use `--force` argument to avoid prompts."),
|
||||
'--enable-proposed-api (<extension-id>)': localize('experimentalApis', "Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.")
|
||||
};
|
||||
|
||||
@@ -203,7 +213,7 @@ export function formatOptions(options: { [name: string]: string; }, columns: num
|
||||
let argLength = Math.max.apply(null, keys.map(k => k.length)) + 2/*left padding*/ + 1/*right padding*/;
|
||||
if (columns - argLength < 25) {
|
||||
// Use a condensed version on narrow terminals
|
||||
return keys.reduce((r, key) => r.concat([` ${key}`, ` ${options[key]}`]), []).join('\n');
|
||||
return keys.reduce((r, key) => r.concat([` ${key}`, ` ${options[key]}`]), [] as string[]).join('\n');
|
||||
}
|
||||
let descriptionColumns = columns - argLength - 1;
|
||||
let result = '';
|
||||
@@ -251,3 +261,30 @@ ${formatOptions(extensionsHelp, columns)}
|
||||
${ localize('troubleshooting', "Troubleshooting")}:
|
||||
${formatOptions(troubleshootingHelp, columns)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an argument into an array
|
||||
* @param arg a argument value. Can be undefined, an entry or an array
|
||||
*/
|
||||
export function asArray(arg: string | string[] | undefined): string[] {
|
||||
if (arg) {
|
||||
if (Array.isArray(arg)) {
|
||||
return arg;
|
||||
}
|
||||
return [arg];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an argument is present.
|
||||
*/
|
||||
export function hasArgs(arg: string | string[] | undefined): boolean {
|
||||
if (arg) {
|
||||
if (Array.isArray(arg)) {
|
||||
return !!arg.length;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user