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:
Connor Peet
2022-11-18 18:52:52 -08:00
committed by GitHub
parent 384ba2454f
commit 796ee2bf3c
25 changed files with 229 additions and 116 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
use super::errors::{wrap, AnyError, CommandFailed, WrappedError};
use std::{ffi::OsStr, process::Stdio, borrow::Cow};
use std::{borrow::Cow, ffi::OsStr, process::Stdio};
use tokio::process::Command;
pub async fn capture_command_and_check_status(

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
use std::fmt::Display;
use crate::constants::CONTROL_PORT;
use crate::constants::{APPLICATION_NAME, CONTROL_PORT, QUALITYLESS_PRODUCT_NAME};
// Wraps another error with additional info.
#[derive(Debug, Clone)]
@@ -282,8 +282,11 @@ impl std::fmt::Display for NoInstallInUserProvidedPath {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
f,
"No VS Code installation could be found in {}. You can run `code --use-quality=stable` to switch to the latest stable version of VS Code.",
self.0
"No {} installation could be found in {}. You can run `{} --use-quality=stable` to switch to the latest stable version of {}.",
QUALITYLESS_PRODUCT_NAME,
self.0,
APPLICATION_NAME,
QUALITYLESS_PRODUCT_NAME
)
}
}
@@ -378,7 +381,11 @@ pub struct CorruptDownload(pub String);
impl std::fmt::Display for CorruptDownload {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "Error updating the VS Code CLI: {}", self.0)
write!(
f,
"Error updating the {} CLI: {}",
QUALITYLESS_PRODUCT_NAME, self.0
)
}
}

View File

@@ -46,7 +46,7 @@ pub fn prompt_yn(text: &str) -> Result<bool, WrappedError> {
.map_err(|e| wrap(e, "Failed to read confirm input"))
}
pub fn prompt_options<T>(text: &str, options: &[T]) -> Result<T, WrappedError>
pub fn prompt_options<T>(text: impl Into<String>, options: &[T]) -> Result<T, WrappedError>
where
T: Display + Copy,
{

View File

@@ -5,6 +5,7 @@
use std::cmp::Ordering;
use super::command::capture_command;
use crate::constants::QUALITYLESS_SERVER_NAME;
use crate::update_service::Platform;
use crate::util::errors::SetupError;
use lazy_static::lazy_static;
@@ -41,8 +42,13 @@ impl PreReqChecker {
#[cfg(not(target_os = "linux"))]
pub async fn verify(&self) -> Result<Platform, AnyError> {
use crate::constants::QUALITYLESS_PRODUCT_NAME;
Platform::env_default().ok_or_else(|| {
SetupError("VS Code is not supported on this platform".to_owned()).into()
SetupError(format!(
"{} is not supported on this platform",
QUALITYLESS_PRODUCT_NAME
))
.into()
})
}
@@ -91,8 +97,8 @@ impl PreReqChecker {
.join("\n");
Err(AnyError::from(SetupError(format!(
"This machine not meet VS Code Server's prerequisites, expected either...\n{}",
bullets,
"This machine not meet {}'s prerequisites, expected either...\n{}",
QUALITYLESS_SERVER_NAME, bullets,
))))
}
}
@@ -107,8 +113,8 @@ async fn check_musl_interpreter() -> Result<(), String> {
if fs::metadata(MUSL_PATH).await.is_err() {
return Err(format!(
"find {}, which is required to run the VS Code Server in musl environments",
MUSL_PATH
"find {}, which is required to run the {} in musl environments",
MUSL_PATH, QUALITYLESS_SERVER_NAME
));
}