Skip to content

Commit 796ee2b

Browse files
authored
chore: pull more strings from the product.json (microsoft#166769)
Fixes the bulk of microsoft/vscode-remote-tunnels#560
1 parent 384ba24 commit 796ee2b

25 files changed

+229
-116
lines changed

build/azure-pipelines/cli/prepare.js

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/azure-pipelines/cli/prepare.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ const setLauncherEnvironmentVars = () => {
4848
['VSCODE_CLI_QUALITY', product.quality],
4949
['VSCODE_CLI_NAME_SHORT', product.nameShort],
5050
['VSCODE_CLI_NAME_LONG', product.nameLong],
51+
['VSCODE_CLI_QUALITYLESS_PRODUCT_NAME', product.nameLong.replace(/ - [a-z]+$/i, '')],
5152
['VSCODE_CLI_APPLICATION_NAME', product.applicationName],
53+
['VSCODE_CLI_EDITOR_WEB_URL', product.editorWebUrl],
5254
['VSCODE_CLI_COMMIT', commit],
5355
[
5456
'VSCODE_CLI_WIN32_APP_IDS',
@@ -58,13 +60,25 @@ const setLauncherEnvironmentVars = () => {
5860
.map(([, value]) => String(value).replace(/[{}]/g, ''))),
5961
),
6062
],
63+
[
64+
'VSCODE_CLI_NAME_LONG_MAP',
65+
!isOSS && JSON.stringify(makeQualityMap(json => json.nameLong)),
66+
],
67+
[
68+
'VSCODE_CLI_APPLICATION_NAME_MAP',
69+
!isOSS && JSON.stringify(makeQualityMap(json => json.applicationName)),
70+
],
71+
[
72+
'VSCODE_CLI_SERVER_NAME_MAP',
73+
!isOSS && JSON.stringify(makeQualityMap(json => json.serverApplicationName)),
74+
],
6175
[
6276
'VSCODE_CLI_QUALITY_DOWNLOAD_URIS',
6377
!isOSS && JSON.stringify(makeQualityMap(json => json.downloadUrl)),
6478
],
6579
]);
6680

67-
console.log(JSON.stringify([...vars].reduce((obj, kv) => ({...obj, [kv[0]]: kv[1]}), {})));
81+
console.log(JSON.stringify([...vars].reduce((obj, kv) => ({ ...obj, [kv[0]]: kv[1] }), {})));
6882

6983
for (const [key, value] of vars) {
7084
if (value) {

cli/Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ clap_lex = "0.2"
4646
url = "2.3"
4747
async-trait = "0.1"
4848
log = "0.4"
49+
const_format = "0.2"
4950

5051
[target.'cfg(windows)'.dependencies]
5152
windows-service = "0.5"

cli/src/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
use crate::{
7-
constants::get_default_user_agent,
7+
constants::{get_default_user_agent, PRODUCT_NAME_LONG},
88
info, log,
99
state::{LauncherPaths, PersistedState},
1010
trace,
@@ -500,7 +500,7 @@ impl Auth {
500500
}
501501

502502
let provider = prompt_options(
503-
"How would you like to log in to VS Code?",
503+
format!("How would you like to log in to {}?", PRODUCT_NAME_LONG),
504504
&[AuthProvider::Microsoft, AuthProvider::Github],
505505
)?;
506506

cli/src/bin/code/main.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ async fn start_code(context: CommandContext, args: Vec<String>) -> Result<i32, A
157157
.args(args)
158158
.status()
159159
.map(|s| s.code().unwrap_or(1))
160-
.map_err(|e| {
161-
wrap(
162-
e,
163-
format!("error running VS Code from {}", binary.display()),
164-
)
165-
})?;
160+
.map_err(|e| wrap(e, format!("error running editor from {}", binary.display())))?;
166161

167162
Ok(code)
168163
}

cli/src/commands/args.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,29 @@ use std::{fmt, path::PathBuf};
77

88
use crate::{constants, log, options, tunnels::code_server::CodeServerArgs};
99
use clap::{ArgEnum, Args, Parser, Subcommand};
10+
use const_format::concatcp;
1011

11-
const TEMPLATE: &str = "
12-
Visual Studio Code CLI - {version}
12+
const CLI_NAME: &str = concatcp!(constants::PRODUCT_NAME_LONG, " CLI");
13+
const TEMPLATE: &str = concatcp!(
14+
CLI_NAME,
15+
" - {version}
1316
14-
Usage: code-insiders.exe [options][paths...]
17+
Usage: ",
18+
constants::APPLICATION_NAME,
19+
" [options][paths...]
1520
16-
To read output from another program, append '-' (e.g. 'echo Hello World | code-insiders.exe -')
21+
To read output from another program, append '-' (e.g. 'echo Hello World | ",
22+
constants::APPLICATION_NAME,
23+
" -')
1724
18-
{all-args}";
25+
{all-args}"
26+
);
1927

2028
#[derive(Parser, Debug, Default)]
2129
#[clap(
2230
help_template = TEMPLATE,
2331
long_about = None,
24-
name = "Visual Studio Code CLI",
32+
name = CLI_NAME,
2533
version = match constants::VSCODE_CLI_VERSION { Some(v) => v, None => "dev" },
2634
)]
2735
pub struct IntegratedCli {
@@ -53,7 +61,7 @@ pub struct CliCore {
5361
#[clap(
5462
help_template = TEMPLATE,
5563
long_about = None,
56-
name = "Visual Studio Code CLI",
64+
name = CLI_NAME,
5765
version = match constants::VSCODE_CLI_VERSION { Some(v) => v, None => "dev" },
5866
)]
5967
pub struct StandaloneCli {
@@ -115,7 +123,7 @@ impl<'a> From<&'a CliCore> for CodeServerArgs {
115123

116124
#[derive(Subcommand, Debug, Clone)]
117125
pub enum StandaloneCommands {
118-
/// Updates the VS Code CLI.
126+
/// Updates the CLI.
119127
Update(StandaloneUpdateArgs),
120128
}
121129

@@ -133,14 +141,14 @@ pub enum Commands {
133141
/// Run `code tunnel --help` for more usage info.
134142
Tunnel(TunnelArgs),
135143

136-
/// Manage VS Code extensions.
144+
/// Manage editor extensions.
137145
#[clap(name = "ext")]
138146
Extension(ExtensionArgs),
139147

140148
/// Print process usage and diagnostics information.
141149
Status,
142150

143-
/// Changes the version of VS Code you're using.
151+
/// Changes the version of the editor you're using.
144152
Version(VersionArgs),
145153
}
146154

@@ -251,16 +259,16 @@ pub struct VersionArgs {
251259

252260
#[derive(Subcommand, Debug, Clone)]
253261
pub enum VersionSubcommand {
254-
/// Switches the instance of VS Code in use.
262+
/// Switches the version of the editor in use.
255263
Use(UseVersionArgs),
256264

257-
/// Shows the currently configured VS Code version.
265+
/// Shows the currently configured editor version.
258266
Show,
259267
}
260268

261269
#[derive(Args, Debug, Clone)]
262270
pub struct UseVersionArgs {
263-
/// The version of VS Code you want to use. Can be "stable", "insiders",
271+
/// The version of the editor you want to use. Can be "stable", "insiders",
264272
/// a version number, or an absolute path to an existing install.
265273
#[clap(value_name = "stable | insiders | x.y.z | path")]
266274
pub name: String,
@@ -346,19 +354,19 @@ impl EditorOptions {
346354
}
347355
}
348356

349-
/// Arguments applicable whenever VS Code desktop is launched
357+
/// Arguments applicable whenever the desktop editor is launched
350358
#[derive(Args, Debug, Default, Clone)]
351359
pub struct DesktopCodeOptions {
352360
/// Set the root path for extensions.
353361
#[clap(long, value_name = "dir")]
354362
pub extensions_dir: Option<String>,
355363

356364
/// Specifies the directory that user data is kept in. Can be used to
357-
/// open multiple distinct instances of Code.
365+
/// open multiple distinct instances of the editor.
358366
#[clap(long, value_name = "dir")]
359367
pub user_data_dir: Option<String>,
360368

361-
/// Sets the VS Code version to use for this command. The preferred version
369+
/// Sets the editor version to use for this command. The preferred version
362370
/// can be persisted with `code version use <version>`. Can be "stable",
363371
/// "insiders", a version number, or an absolute path to an existing install.
364372
#[clap(long, value_name = "stable | insiders | x.y.z | path")]
@@ -386,7 +394,7 @@ impl DesktopCodeOptions {
386394

387395
#[derive(Args, Debug, Default, Clone)]
388396
pub struct GlobalOptions {
389-
/// Directory where CLI metadata, such as VS Code installations, should be stored.
397+
/// Directory where CLI metadata should be stored.
390398
#[clap(long, env = "VSCODE_CLI_DATA_DIR", global = true)]
391399
pub cli_data_dir: Option<String>,
392400

@@ -464,7 +472,7 @@ pub struct EditorTroubleshooting {
464472
#[clap(long, value_name = "memory")]
465473
pub max_memory: Option<usize>,
466474

467-
/// Shows all telemetry events which VS code collects.
475+
/// Shows all telemetry events which the editor collects.
468476
#[clap(long)]
469477
pub telemetry: bool,
470478
}

cli/src/commands/update.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use indicatif::ProgressBar;
77

88
use crate::{
9+
constants::PRODUCT_NAME_LONG,
910
self_update::SelfUpdate,
1011
update_service::UpdateService,
1112
util::{errors::AnyError, http::ReqwestSimpleHttp, input::ProgressBarReporter},
@@ -23,8 +24,8 @@ pub async fn update(ctx: CommandContext, args: StandaloneUpdateArgs) -> Result<i
2324
let current_version = update_service.get_current_release().await?;
2425
if update_service.is_up_to_date_with(&current_version) {
2526
ctx.log.result(format!(
26-
"VS Code is already to to date ({})",
27-
current_version.commit
27+
"{} is already to to date ({})",
28+
PRODUCT_NAME_LONG, current_version.commit
2829
));
2930
return Ok(1);
3031
}

cli/src/commands/version.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,5 @@ pub async fn show(ctx: CommandContext) -> Result<i32, AnyError> {
5858
}
5959

6060
fn print_now_using(log: &log::Logger, version: &RequestedVersion, path: &Path) {
61-
log.result(&format!(
62-
"Now using VS Code {} from {}",
63-
version,
64-
path.display()
65-
));
61+
log.result(&format!("Now using {} from {}", version, path.display()));
6662
}

0 commit comments

Comments
 (0)