mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
chore: pull more strings from the product.json (#166769)
Fixes the bulk of https://github.com/microsoft/vscode-cli/issues/560
This commit is contained in:
@@ -7,6 +7,8 @@ use std::fmt;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::constants::{APPLICATION_NAME_MAP, PRODUCT_NAME_LONG_MAP, SERVER_NAME_MAP};
|
||||
|
||||
#[derive(clap::ArgEnum, Copy, Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Quality {
|
||||
#[serde(rename = "stable")]
|
||||
@@ -18,7 +20,7 @@ pub enum Quality {
|
||||
}
|
||||
|
||||
impl Quality {
|
||||
/// Lowercased name in paths and protocol
|
||||
/// Lowercased quality name in paths and protocol
|
||||
pub fn get_machine_name(&self) -> &'static str {
|
||||
match self {
|
||||
Quality::Insiders => "insiders",
|
||||
@@ -27,7 +29,7 @@ impl Quality {
|
||||
}
|
||||
}
|
||||
|
||||
/// Uppercased display name for humans
|
||||
/// Uppercased quality display name for humans
|
||||
pub fn get_capitalized_name(&self) -> &'static str {
|
||||
match self {
|
||||
Quality::Insiders => "Insiders",
|
||||
@@ -36,37 +38,38 @@ impl Quality {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_macos_app_name(&self) -> &'static str {
|
||||
match self {
|
||||
Quality::Insiders => "Visual Studio Code - Insiders",
|
||||
Quality::Exploration => "Visual Studio Code - Exploration",
|
||||
Quality::Stable => "Visual Studio Code",
|
||||
}
|
||||
/// Product long name
|
||||
pub fn get_long_name(&self) -> &'static str {
|
||||
PRODUCT_NAME_LONG_MAP
|
||||
.as_ref()
|
||||
.and_then(|m| m.get(self))
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("Code - OSS")
|
||||
}
|
||||
|
||||
pub fn get_commandline_name(&self) -> &'static str {
|
||||
match self {
|
||||
Quality::Insiders => "code-insiders",
|
||||
Quality::Exploration => "code-exploration",
|
||||
Quality::Stable => "code",
|
||||
}
|
||||
/// Product application name
|
||||
pub fn get_application_name(&self) -> &'static str {
|
||||
APPLICATION_NAME_MAP
|
||||
.as_ref()
|
||||
.and_then(|m| m.get(self))
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("code")
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn server_entrypoint(&self) -> &'static str {
|
||||
match self {
|
||||
Quality::Insiders => "code-server-insiders.cmd",
|
||||
Quality::Exploration => "code-server-exploration.cmd",
|
||||
Quality::Stable => "code-server.cmd",
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn server_entrypoint(&self) -> &'static str {
|
||||
match self {
|
||||
Quality::Insiders => "code-server-insiders",
|
||||
Quality::Exploration => "code-server-exploration",
|
||||
Quality::Stable => "code-server",
|
||||
/// Server application name
|
||||
pub fn server_entrypoint(&self) -> String {
|
||||
let mut server_name = SERVER_NAME_MAP
|
||||
.as_ref()
|
||||
.and_then(|m| m.get(self))
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("code-server-oss")
|
||||
.to_string();
|
||||
|
||||
if cfg!(windows) {
|
||||
server_name.push_str(".cmd");
|
||||
}
|
||||
|
||||
server_name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user