mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
style: simplify string formatting for readability (#231763)
* style: simplify string formatting for readability * fix: formatting in `.rs` files in `src/`
This commit is contained in:
@@ -133,7 +133,7 @@ fn apply_build_environment_variables() {
|
|||||||
} else {
|
} else {
|
||||||
PathBuf::from_str(&v).unwrap()
|
PathBuf::from_str(&v).unwrap()
|
||||||
};
|
};
|
||||||
println!("cargo:warning=loading product.json from <{:?}>", path);
|
println!("cargo:warning=loading product.json from <{path:?}>");
|
||||||
apply_build_from_product_json(&path);
|
apply_build_from_product_json(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,10 +93,9 @@ impl AuthProvider {
|
|||||||
|
|
||||||
pub fn get_default_scopes(&self) -> String {
|
pub fn get_default_scopes(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
AuthProvider::Microsoft => format!(
|
AuthProvider::Microsoft => {
|
||||||
"{}/.default+offline_access+profile+openid",
|
format!("{PROD_FIRST_PARTY_APP_ID}/.default+offline_access+profile+openid")
|
||||||
PROD_FIRST_PARTY_APP_ID
|
}
|
||||||
),
|
|
||||||
AuthProvider::Github => "read:user+read:org".to_string(),
|
AuthProvider::Github => "read:user+read:org".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +121,7 @@ async fn get_github_user(
|
|||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
client
|
client
|
||||||
.get(GH_USER_ENDPOINT)
|
.get(GH_USER_ENDPOINT)
|
||||||
.header("Authorization", format!("token {}", access_token))
|
.header("Authorization", format!("token {access_token}"))
|
||||||
.header("User-Agent", get_default_user_agent())
|
.header("User-Agent", get_default_user_agent())
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
@@ -690,7 +689,7 @@ impl Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let provider = prompt_options(
|
let provider = prompt_options(
|
||||||
format!("How would you like to log in to {}?", PRODUCT_NAME_LONG),
|
format!("How would you like to log in to {PRODUCT_NAME_LONG}?"),
|
||||||
&[AuthProvider::Microsoft, AuthProvider::Github],
|
&[AuthProvider::Microsoft, AuthProvider::Github],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ fn print_and_exit<E>(err: E) -> !
|
|||||||
where
|
where
|
||||||
E: std::fmt::Display,
|
E: std::fmt::Display,
|
||||||
{
|
{
|
||||||
log::emit(log::Level::Error, "", &format!("{}", err));
|
log::emit(log::Level::Error, "", &format!("{err}"));
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,12 +283,12 @@ impl ExtensionSubcommand {
|
|||||||
target.push("--show-versions".to_string());
|
target.push("--show-versions".to_string());
|
||||||
}
|
}
|
||||||
if let Some(category) = &args.category {
|
if let Some(category) = &args.category {
|
||||||
target.push(format!("--category={}", category));
|
target.push(format!("--category={category}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExtensionSubcommand::Install(args) => {
|
ExtensionSubcommand::Install(args) => {
|
||||||
for id in args.id_or_path.iter() {
|
for id in args.id_or_path.iter() {
|
||||||
target.push(format!("--install-extension={}", id));
|
target.push(format!("--install-extension={id}"));
|
||||||
}
|
}
|
||||||
if args.pre_release {
|
if args.pre_release {
|
||||||
target.push("--pre-release".to_string());
|
target.push("--pre-release".to_string());
|
||||||
@@ -299,7 +299,7 @@ impl ExtensionSubcommand {
|
|||||||
}
|
}
|
||||||
ExtensionSubcommand::Uninstall(args) => {
|
ExtensionSubcommand::Uninstall(args) => {
|
||||||
for id in args.id.iter() {
|
for id in args.id.iter() {
|
||||||
target.push(format!("--uninstall-extension={}", id));
|
target.push(format!("--uninstall-extension={id}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExtensionSubcommand::Update => {
|
ExtensionSubcommand::Update => {
|
||||||
@@ -439,11 +439,11 @@ impl EditorOptions {
|
|||||||
target.push("--wait".to_string());
|
target.push("--wait".to_string());
|
||||||
}
|
}
|
||||||
if let Some(locale) = &self.locale {
|
if let Some(locale) = &self.locale {
|
||||||
target.push(format!("--locale={}", locale));
|
target.push(format!("--locale={locale}"));
|
||||||
}
|
}
|
||||||
if !self.enable_proposed_api.is_empty() {
|
if !self.enable_proposed_api.is_empty() {
|
||||||
for id in self.enable_proposed_api.iter() {
|
for id in self.enable_proposed_api.iter() {
|
||||||
target.push(format!("--enable-proposed-api={}", id));
|
target.push(format!("--enable-proposed-api={id}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.code_options.add_code_args(target);
|
self.code_options.add_code_args(target);
|
||||||
@@ -480,10 +480,10 @@ pub struct OutputFormatOptions {
|
|||||||
impl DesktopCodeOptions {
|
impl DesktopCodeOptions {
|
||||||
pub fn add_code_args(&self, target: &mut Vec<String>) {
|
pub fn add_code_args(&self, target: &mut Vec<String>) {
|
||||||
if let Some(extensions_dir) = &self.extensions_dir {
|
if let Some(extensions_dir) = &self.extensions_dir {
|
||||||
target.push(format!("--extensions-dir={}", extensions_dir));
|
target.push(format!("--extensions-dir={extensions_dir}"));
|
||||||
}
|
}
|
||||||
if let Some(user_data_dir) = &self.user_data_dir {
|
if let Some(user_data_dir) = &self.user_data_dir {
|
||||||
target.push(format!("--user-data-dir={}", user_data_dir));
|
target.push(format!("--user-data-dir={user_data_dir}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,13 +522,13 @@ impl GlobalOptions {
|
|||||||
target.push("--verbose".to_string());
|
target.push("--verbose".to_string());
|
||||||
}
|
}
|
||||||
if let Some(log) = self.log {
|
if let Some(log) = self.log {
|
||||||
target.push(format!("--log={}", log));
|
target.push(format!("--log={log}"));
|
||||||
}
|
}
|
||||||
if self.disable_telemetry {
|
if self.disable_telemetry {
|
||||||
target.push("--disable-telemetry".to_string());
|
target.push("--disable-telemetry".to_string());
|
||||||
}
|
}
|
||||||
if let Some(telemetry_level) = &self.telemetry_level {
|
if let Some(telemetry_level) = &self.telemetry_level {
|
||||||
target.push(format!("--telemetry-level={}", telemetry_level));
|
target.push(format!("--telemetry-level={telemetry_level}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -578,16 +578,16 @@ impl EditorTroubleshooting {
|
|||||||
target.push("--disable-extensions".to_string());
|
target.push("--disable-extensions".to_string());
|
||||||
}
|
}
|
||||||
for id in self.disable_extension.iter() {
|
for id in self.disable_extension.iter() {
|
||||||
target.push(format!("--disable-extension={}", id));
|
target.push(format!("--disable-extension={id}"));
|
||||||
}
|
}
|
||||||
if let Some(sync) = &self.sync {
|
if let Some(sync) = &self.sync {
|
||||||
target.push(format!("--sync={}", sync));
|
target.push(format!("--sync={sync}"));
|
||||||
}
|
}
|
||||||
if let Some(port) = &self.inspect_extensions {
|
if let Some(port) = &self.inspect_extensions {
|
||||||
target.push(format!("--inspect-extensions={}", port));
|
target.push(format!("--inspect-extensions={port}"));
|
||||||
}
|
}
|
||||||
if let Some(port) = &self.inspect_brk_extensions {
|
if let Some(port) = &self.inspect_brk_extensions {
|
||||||
target.push(format!("--inspect-brk-extensions={}", port));
|
target.push(format!("--inspect-brk-extensions={port}"));
|
||||||
}
|
}
|
||||||
if self.disable_gpu {
|
if self.disable_gpu {
|
||||||
target.push("--disable-gpu".to_string());
|
target.push("--disable-gpu".to_string());
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ pub async fn serve_web(ctx: CommandContext, mut args: ServeWebArgs) -> Result<i3
|
|||||||
};
|
};
|
||||||
let builder = Server::try_bind(&addr).map_err(CodeError::CouldNotListenOnInterface)?;
|
let builder = Server::try_bind(&addr).map_err(CodeError::CouldNotListenOnInterface)?;
|
||||||
|
|
||||||
let mut listening = format!("Web UI available at http://{}", addr);
|
let mut listening = format!("Web UI available at http://{addr}");
|
||||||
if let Some(base) = args.server_base_path {
|
if let Some(base) = args.server_base_path {
|
||||||
if !base.starts_with('/') {
|
if !base.starts_with('/') {
|
||||||
listening.push('/');
|
listening.push('/');
|
||||||
@@ -133,7 +133,7 @@ pub async fn serve_web(ctx: CommandContext, mut args: ServeWebArgs) -> Result<i3
|
|||||||
listening.push_str(&base);
|
listening.push_str(&base);
|
||||||
}
|
}
|
||||||
if let Some(ct) = args.connection_token {
|
if let Some(ct) = args.connection_token {
|
||||||
listening.push_str(&format!("?tkn={}", ct));
|
listening.push_str(&format!("?tkn={ct}"));
|
||||||
}
|
}
|
||||||
ctx.log.result(listening);
|
ctx.log.result(listening);
|
||||||
|
|
||||||
@@ -223,12 +223,9 @@ fn append_secret_headers(
|
|||||||
let headers = res.headers_mut();
|
let headers = res.headers_mut();
|
||||||
headers.append(
|
headers.append(
|
||||||
hyper::header::SET_COOKIE,
|
hyper::header::SET_COOKIE,
|
||||||
format!(
|
format!("{PATH_COOKIE_NAME}={base_path}{SECRET_KEY_MINT_PATH}; SameSite=Strict; Path=/",)
|
||||||
"{}={}{}; SameSite=Strict; Path=/",
|
.parse()
|
||||||
PATH_COOKIE_NAME, base_path, SECRET_KEY_MINT_PATH,
|
.unwrap(),
|
||||||
)
|
|
||||||
.parse()
|
|
||||||
.unwrap(),
|
|
||||||
);
|
);
|
||||||
headers.append(
|
headers.append(
|
||||||
hyper::header::SET_COOKIE,
|
hyper::header::SET_COOKIE,
|
||||||
@@ -445,14 +442,14 @@ mod response {
|
|||||||
pub fn connection_err(err: hyper::Error) -> Response<Body> {
|
pub fn connection_err(err: hyper::Error) -> Response<Body> {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(503)
|
.status(503)
|
||||||
.body(Body::from(format!("Error connecting to server: {:?}", err)))
|
.body(Body::from(format!("Error connecting to server: {err:?}")))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn code_err(err: CodeError) -> Response<Body> {
|
pub fn code_err(err: CodeError) -> Response<Body> {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(500)
|
.status(500)
|
||||||
.body(Body::from(format!("Error serving request: {}", err)))
|
.body(Body::from(format!("Error serving request: {err}")))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Resul
|
|||||||
match socket {
|
match socket {
|
||||||
Ok((read, write)) => servers.push(serve_stream(read, write, params.clone())),
|
Ok((read, write)) => servers.push(serve_stream(read, write, params.clone())),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(params.log, &format!("Error accepting connection: {}", e));
|
error!(params.log, &format!("Error accepting connection: {e}"));
|
||||||
return Ok(1);
|
return Ok(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ pub async fn service(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
ctx.log.result(format!("Service successfully installed! You can use `{} tunnel service log` to monitor it, and `{} tunnel service uninstall` to remove it.", APPLICATION_NAME, APPLICATION_NAME));
|
ctx.log.result(format!("Service successfully installed! You can use `{APPLICATION_NAME} tunnel service log` to monitor it, and `{APPLICATION_NAME} tunnel service uninstall` to remove it."));
|
||||||
}
|
}
|
||||||
TunnelServiceSubCommands::Uninstall => {
|
TunnelServiceSubCommands::Uninstall => {
|
||||||
manager.unregister().await?;
|
manager.unregister().await?;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub async fn update(ctx: CommandContext, args: StandaloneUpdateArgs) -> Result<i
|
|||||||
|
|
||||||
if args.check {
|
if args.check {
|
||||||
ctx.log
|
ctx.log
|
||||||
.result(format!("Update to {} is available", current_version));
|
.result(format!("Update to {current_version} is available"));
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ pub async fn update(ctx: CommandContext, args: StandaloneUpdateArgs) -> Result<i
|
|||||||
.do_update(¤t_version, ProgressBarReporter::from(pb))
|
.do_update(¤t_version, ProgressBarReporter::from(pb))
|
||||||
.await?;
|
.await?;
|
||||||
ctx.log
|
ctx.log
|
||||||
.result(format!("Successfully updated to {}", current_version));
|
.result(format!("Successfully updated to {current_version}"));
|
||||||
|
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ pub async fn show(ctx: CommandContext) -> Result<i32, AnyError> {
|
|||||||
let vm = CodeVersionManager::new(ctx.log.clone(), &ctx.paths, platform);
|
let vm = CodeVersionManager::new(ctx.log.clone(), &ctx.paths, platform);
|
||||||
|
|
||||||
let version = vm.get_preferred_version();
|
let version = vm.get_preferred_version();
|
||||||
println!("Current quality: {}", version);
|
println!("Current quality: {version}");
|
||||||
match vm.try_get_entrypoint(&version).await {
|
match vm.try_get_entrypoint(&version).await {
|
||||||
Some(p) => println!("Installation path: {}", p.display()),
|
Some(p) => println!("Installation path: {}", p.display()),
|
||||||
None => println!("No existing installation found"),
|
None => println!("No existing installation found"),
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ impl RequestedVersion {
|
|||||||
pub fn get_command(&self) -> String {
|
pub fn get_command(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
RequestedVersion::Default => {
|
RequestedVersion::Default => {
|
||||||
format!("code version use {}", QUALITY)
|
format!("code version use {QUALITY}")
|
||||||
}
|
}
|
||||||
RequestedVersion::Commit(commit) => {
|
RequestedVersion::Commit(commit) => {
|
||||||
format!("code version use {}/{}", QUALITY, commit)
|
format!("code version use {QUALITY}/{commit}")
|
||||||
}
|
}
|
||||||
RequestedVersion::Path(path) => {
|
RequestedVersion::Path(path) => {
|
||||||
format!("code version use {}", path)
|
format!("code version use {path}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,12 +57,12 @@ impl std::fmt::Display for RequestedVersion {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
RequestedVersion::Default => {
|
RequestedVersion::Default => {
|
||||||
write!(f, "{}", QUALITY)
|
write!(f, "{QUALITY}")
|
||||||
}
|
}
|
||||||
RequestedVersion::Commit(commit) => {
|
RequestedVersion::Commit(commit) => {
|
||||||
write!(f, "{}/{}", QUALITY, commit)
|
write!(f, "{QUALITY}/{commit}")
|
||||||
}
|
}
|
||||||
RequestedVersion::Path(path) => write!(f, "{}", path),
|
RequestedVersion::Path(path) => write!(f, "{path}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,17 +222,14 @@ impl CodeVersionManager {
|
|||||||
/// Shows a nice UI prompt to users asking them if they want to install the
|
/// Shows a nice UI prompt to users asking them if they want to install the
|
||||||
/// requested version.
|
/// requested version.
|
||||||
pub fn prompt_to_install(version: &RequestedVersion) {
|
pub fn prompt_to_install(version: &RequestedVersion) {
|
||||||
println!(
|
println!("No installation of {QUALITYLESS_PRODUCT_NAME} {version} was found.");
|
||||||
"No installation of {} {} was found.",
|
|
||||||
QUALITYLESS_PRODUCT_NAME, version
|
|
||||||
);
|
|
||||||
|
|
||||||
if let RequestedVersion::Default = version {
|
if let RequestedVersion::Default = version {
|
||||||
if let Some(uri) = PRODUCT_DOWNLOAD_URL {
|
if let Some(uri) = PRODUCT_DOWNLOAD_URL {
|
||||||
// todo: on some platforms, we may be able to help automate installation. For example,
|
// todo: on some platforms, we may be able to help automate installation. For example,
|
||||||
// we can unzip the app ourselves on macOS and on windows we can download and spawn the GUI installer
|
// we can unzip the app ourselves on macOS and on windows we can download and spawn the GUI installer
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
println!("Install it from your system's package manager or {}, restart your shell, and try again.", uri);
|
println!("Install it from your system's package manager or {uri}, restart your shell, and try again.");
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
println!("Download and unzip it from {} and try again.", uri);
|
println!("Download and unzip it from {} and try again.", uri);
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
@@ -447,7 +444,7 @@ mod tests {
|
|||||||
// developers can run this test and debug output manually; VS Code will not
|
// developers can run this test and debug output manually; VS Code will not
|
||||||
// be installed in CI, so the test only makes sure it doesn't error out
|
// be installed in CI, so the test only makes sure it doesn't error out
|
||||||
let result = detect_installed_program(&log::Logger::test());
|
let result = detect_installed_program(&log::Logger::test());
|
||||||
println!("result: {:?}", result);
|
println!("result: {result:?}");
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ impl DownloadCache {
|
|||||||
return Ok(target_dir);
|
return Ok(target_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
let temp_dir = self.path.join(format!("{}{}", name, STAGING_SUFFIX));
|
let temp_dir = self.path.join(format!("{name}{STAGING_SUFFIX}"));
|
||||||
let _ = remove_dir_all(&temp_dir).await; // cleanup any existing
|
let _ = remove_dir_all(&temp_dir).await; // cleanup any existing
|
||||||
|
|
||||||
create_dir_all(&temp_dir).map_err(|e| wrap(e, "error creating server directory"))?;
|
create_dir_all(&temp_dir).map_err(|e| wrap(e, "error creating server directory"))?;
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ impl LogSink for StdioLogSink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn write_result(&self, message: &str) {
|
fn write_result(&self, message: &str) {
|
||||||
println!("{}", message);
|
println!("{message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ impl Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn span(&self, name: &str) -> SpanBuilder {
|
pub fn span(&self, name: &str) -> SpanBuilder {
|
||||||
self.tracer.span_builder(format!("serverlauncher/{}", name))
|
self.tracer.span_builder(format!("serverlauncher/{name}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tracer(&self) -> &Tracer {
|
pub fn tracer(&self) -> &Tracer {
|
||||||
@@ -237,8 +237,8 @@ impl Logger {
|
|||||||
pub fn prefixed(&self, prefix: &str) -> Logger {
|
pub fn prefixed(&self, prefix: &str) -> Logger {
|
||||||
Logger {
|
Logger {
|
||||||
prefix: Some(match &self.prefix {
|
prefix: Some(match &self.prefix {
|
||||||
Some(p) => format!("{}{} ", p, prefix),
|
Some(p) => format!("{p}{prefix} "),
|
||||||
None => format!("{} ", prefix),
|
None => format!("{prefix} "),
|
||||||
}),
|
}),
|
||||||
..self.clone()
|
..self.clone()
|
||||||
}
|
}
|
||||||
@@ -312,22 +312,19 @@ fn format(level: Level, prefix: &str, message: &str, use_colors: bool) -> String
|
|||||||
|
|
||||||
if use_colors {
|
if use_colors {
|
||||||
if let Some(c) = level.color_code() {
|
if let Some(c) = level.color_code() {
|
||||||
return format!(
|
return format!("\x1b[2m[{timestamp}]\x1b[0m {c}{name}\x1b[0m {prefix}{message}\n");
|
||||||
"\x1b[2m[{}]\x1b[0m {}{}\x1b[0m {}{}\n",
|
|
||||||
timestamp, c, name, prefix, message
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format!("[{}] {} {}{}\n", timestamp, name, prefix, message)
|
format!("[{timestamp}] {name} {prefix}{message}\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit(level: Level, prefix: &str, message: &str) {
|
pub fn emit(level: Level, prefix: &str, message: &str) {
|
||||||
let line = format(level, prefix, message, *COLORS_ENABLED);
|
let line = format(level, prefix, message, *COLORS_ENABLED);
|
||||||
if level == Level::Trace && *COLORS_ENABLED {
|
if level == Level::Trace && *COLORS_ENABLED {
|
||||||
print!("\x1b[2m{}\x1b[0m", line);
|
print!("\x1b[2m{line}\x1b[0m");
|
||||||
} else {
|
} else {
|
||||||
print!("{}", line);
|
print!("{line}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ impl TryFrom<&str> for Quality {
|
|||||||
"insiders" | "insider" => Ok(Quality::Insiders),
|
"insiders" | "insider" => Ok(Quality::Insiders),
|
||||||
"exploration" => Ok(Quality::Exploration),
|
"exploration" => Ok(Quality::Exploration),
|
||||||
_ => Err(format!(
|
_ => Err(format!(
|
||||||
"Unknown quality: {}. Must be one of stable, insiders, or exploration.",
|
"Unknown quality: {s}. Must be one of stable, insiders, or exploration."
|
||||||
s
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ impl<S: Serialization, C: Send + Sync + 'static> RpcMethodBuilder<S, C> {
|
|||||||
F: Fn(P, &C) -> Result<R, AnyError> + Send + Sync + 'static,
|
F: Fn(P, &C) -> Result<R, AnyError> + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
if self.methods.contains_key(method_name) {
|
if self.methods.contains_key(method_name) {
|
||||||
panic!("Method already registered: {}", method_name);
|
panic!("Method already registered: {method_name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
let serial = self.serializer.clone();
|
let serial = self.serializer.clone();
|
||||||
@@ -121,7 +121,7 @@ impl<S: Serialization, C: Send + Sync + 'static> RpcMethodBuilder<S, C> {
|
|||||||
id,
|
id,
|
||||||
error: ResponseError {
|
error: ResponseError {
|
||||||
code: 0,
|
code: 0,
|
||||||
message: format!("{:?}", err),
|
message: format!("{err:?}"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -135,7 +135,7 @@ impl<S: Serialization, C: Send + Sync + 'static> RpcMethodBuilder<S, C> {
|
|||||||
id,
|
id,
|
||||||
error: ResponseError {
|
error: ResponseError {
|
||||||
code: -1,
|
code: -1,
|
||||||
message: format!("{:?}", err),
|
message: format!("{err:?}"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
@@ -165,7 +165,7 @@ impl<S: Serialization, C: Send + Sync + 'static> RpcMethodBuilder<S, C> {
|
|||||||
id,
|
id,
|
||||||
error: ResponseError {
|
error: ResponseError {
|
||||||
code: 0,
|
code: 0,
|
||||||
message: format!("{:?}", err),
|
message: format!("{err:?}"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
@@ -186,7 +186,7 @@ impl<S: Serialization, C: Send + Sync + 'static> RpcMethodBuilder<S, C> {
|
|||||||
id,
|
id,
|
||||||
error: ResponseError {
|
error: ResponseError {
|
||||||
code: -1,
|
code: -1,
|
||||||
message: format!("{:?}", err),
|
message: format!("{err:?}"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
@@ -226,7 +226,7 @@ impl<S: Serialization, C: Send + Sync + 'static> RpcMethodBuilder<S, C> {
|
|||||||
id,
|
id,
|
||||||
error: ResponseError {
|
error: ResponseError {
|
||||||
code: 0,
|
code: 0,
|
||||||
message: format!("{:?}", err),
|
message: format!("{err:?}"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
@@ -259,7 +259,7 @@ impl<S: Serialization, C: Send + Sync + 'static> RpcMethodBuilder<S, C> {
|
|||||||
id,
|
id,
|
||||||
error: ResponseError {
|
error: ResponseError {
|
||||||
code: -1,
|
code: -1,
|
||||||
message: format!("{:?}", err),
|
message: format!("{err:?}"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
@@ -431,7 +431,7 @@ impl<S: Serialization, C: Send + Sync> RpcDispatcher<S, C> {
|
|||||||
id,
|
id,
|
||||||
error: ResponseError {
|
error: ResponseError {
|
||||||
code: -1,
|
code: -1,
|
||||||
message: format!("Method not found: {}", method_name),
|
message: format!("Method not found: {method_name}"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ fn validate_cli_is_good(exe_path: &Path) -> Result<(), AnyError> {
|
|||||||
let o = new_std_command(exe_path)
|
let o = new_std_command(exe_path)
|
||||||
.args(["--version"])
|
.args(["--version"])
|
||||||
.output()
|
.output()
|
||||||
.map_err(|e| CorruptDownload(format!("could not execute new binary, aborting: {}", e)))?;
|
.map_err(|e| CorruptDownload(format!("could not execute new binary, aborting: {e}")))?;
|
||||||
|
|
||||||
if !o.status.success() {
|
if !o.status.success() {
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
|
|||||||
@@ -155,17 +155,14 @@ impl LauncherPaths {
|
|||||||
|
|
||||||
if let Err(e) = std::fs::rename(&old_dir, &new_dir) {
|
if let Err(e) = std::fs::rename(&old_dir, &new_dir) {
|
||||||
// no logger exists at this point in the lifecycle, so just log to stderr
|
// no logger exists at this point in the lifecycle, so just log to stderr
|
||||||
eprintln!(
|
eprintln!("Failed to migrate old CLI data directory, will create a new one ({e})");
|
||||||
"Failed to migrate old CLI data directory, will create a new one ({})",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::new_for_path(new_dir)
|
Self::new_for_path(new_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(root: Option<String>) -> Result<LauncherPaths, AnyError> {
|
pub fn new(root: Option<String>) -> Result<LauncherPaths, AnyError> {
|
||||||
let root = root.unwrap_or_else(|| format!("~/{}/cli", DEFAULT_DATA_PARENT_DIR));
|
let root = root.unwrap_or_else(|| format!("~/{DEFAULT_DATA_PARENT_DIR}/cli"));
|
||||||
let mut replaced = root.to_owned();
|
let mut replaced = root.to_owned();
|
||||||
for token in HOME_DIR_ALTS {
|
for token in HOME_DIR_ALTS {
|
||||||
if root.contains(token) {
|
if root.contains(token) {
|
||||||
|
|||||||
@@ -91,21 +91,21 @@ impl CodeServerArgs {
|
|||||||
pub fn command_arguments(&self) -> Vec<String> {
|
pub fn command_arguments(&self) -> Vec<String> {
|
||||||
let mut args = Vec::new();
|
let mut args = Vec::new();
|
||||||
if let Some(i) = &self.socket_path {
|
if let Some(i) = &self.socket_path {
|
||||||
args.push(format!("--socket-path={}", i));
|
args.push(format!("--socket-path={i}"));
|
||||||
} else {
|
} else {
|
||||||
if let Some(i) = &self.host {
|
if let Some(i) = &self.host {
|
||||||
args.push(format!("--host={}", i));
|
args.push(format!("--host={i}"));
|
||||||
}
|
}
|
||||||
if let Some(i) = &self.port {
|
if let Some(i) = &self.port {
|
||||||
args.push(format!("--port={}", i));
|
args.push(format!("--port={i}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(i) = &self.connection_token {
|
if let Some(i) = &self.connection_token {
|
||||||
args.push(format!("--connection-token={}", i));
|
args.push(format!("--connection-token={i}"));
|
||||||
}
|
}
|
||||||
if let Some(i) = &self.connection_token_file {
|
if let Some(i) = &self.connection_token_file {
|
||||||
args.push(format!("--connection-token-file={}", i));
|
args.push(format!("--connection-token-file={i}"));
|
||||||
}
|
}
|
||||||
if self.without_connection_token {
|
if self.without_connection_token {
|
||||||
args.push(String::from("--without-connection-token"));
|
args.push(String::from("--without-connection-token"));
|
||||||
@@ -114,14 +114,14 @@ impl CodeServerArgs {
|
|||||||
args.push(String::from("--accept-server-license-terms"));
|
args.push(String::from("--accept-server-license-terms"));
|
||||||
}
|
}
|
||||||
if let Some(i) = self.telemetry_level {
|
if let Some(i) = self.telemetry_level {
|
||||||
args.push(format!("--telemetry-level={}", i));
|
args.push(format!("--telemetry-level={i}"));
|
||||||
}
|
}
|
||||||
if let Some(i) = self.log {
|
if let Some(i) = self.log {
|
||||||
args.push(format!("--log={}", i));
|
args.push(format!("--log={i}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for extension in &self.install_extensions {
|
for extension in &self.install_extensions {
|
||||||
args.push(format!("--install-extension={}", extension));
|
args.push(format!("--install-extension={extension}"));
|
||||||
}
|
}
|
||||||
if !&self.install_extensions.is_empty() {
|
if !&self.install_extensions.is_empty() {
|
||||||
if self.pre_release {
|
if self.pre_release {
|
||||||
@@ -132,7 +132,7 @@ impl CodeServerArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for extension in &self.uninstall_extensions {
|
for extension in &self.uninstall_extensions {
|
||||||
args.push(format!("--uninstall-extension={}", extension));
|
args.push(format!("--uninstall-extension={extension}"));
|
||||||
}
|
}
|
||||||
if self.update_extensions {
|
if self.update_extensions {
|
||||||
args.push(String::from("--update-extensions"));
|
args.push(String::from("--update-extensions"));
|
||||||
@@ -143,14 +143,14 @@ impl CodeServerArgs {
|
|||||||
args.push(String::from("--show-versions"));
|
args.push(String::from("--show-versions"));
|
||||||
}
|
}
|
||||||
if let Some(i) = &self.category {
|
if let Some(i) = &self.category {
|
||||||
args.push(format!("--category={}", i));
|
args.push(format!("--category={i}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(d) = &self.server_data_dir {
|
if let Some(d) = &self.server_data_dir {
|
||||||
args.push(format!("--server-data-dir={}", d));
|
args.push(format!("--server-data-dir={d}"));
|
||||||
}
|
}
|
||||||
if let Some(d) = &self.extensions_dir {
|
if let Some(d) = &self.extensions_dir {
|
||||||
args.push(format!("--extensions-dir={}", d));
|
args.push(format!("--extensions-dir={d}"));
|
||||||
}
|
}
|
||||||
if self.start_server {
|
if self.start_server {
|
||||||
args.push(String::from("--start-server"));
|
args.push(String::from("--start-server"));
|
||||||
@@ -487,7 +487,7 @@ impl<'a> ServerBuilder<'a> {
|
|||||||
let mut cmd = self.get_base_command();
|
let mut cmd = self.get_base_command();
|
||||||
cmd.arg("--start-server")
|
cmd.arg("--start-server")
|
||||||
.arg("--enable-remote-auto-shutdown")
|
.arg("--enable-remote-auto-shutdown")
|
||||||
.arg(format!("--port={}", port));
|
.arg(format!("--port={port}"));
|
||||||
|
|
||||||
let child = self.spawn_server_process(cmd).await?;
|
let child = self.spawn_server_process(cmd).await?;
|
||||||
let log_file = self.get_logfile()?;
|
let log_file = self.get_logfile()?;
|
||||||
@@ -503,7 +503,7 @@ impl<'a> ServerBuilder<'a> {
|
|||||||
}
|
}
|
||||||
Ok(Err(s)) => {
|
Ok(Err(s)) => {
|
||||||
origin.kill().await;
|
origin.kill().await;
|
||||||
return Err(CodeError::ServerUnexpectedExit(format!("{}", s)).into());
|
return Err(CodeError::ServerUnexpectedExit(format!("{s}")).into());
|
||||||
}
|
}
|
||||||
Ok(Ok(p)) => p,
|
Ok(Ok(p)) => p,
|
||||||
};
|
};
|
||||||
@@ -577,7 +577,7 @@ impl<'a> ServerBuilder<'a> {
|
|||||||
}
|
}
|
||||||
Ok(Err(s)) => {
|
Ok(Err(s)) => {
|
||||||
origin.kill().await;
|
origin.kill().await;
|
||||||
return Err(CodeError::ServerUnexpectedExit(format!("{}", s)).into());
|
return Err(CodeError::ServerUnexpectedExit(format!("{s}")).into());
|
||||||
}
|
}
|
||||||
Ok(Ok(socket)) => socket,
|
Ok(Ok(socket)) => socket,
|
||||||
};
|
};
|
||||||
@@ -616,7 +616,7 @@ impl<'a> ServerBuilder<'a> {
|
|||||||
.stderr(std::process::Stdio::piped())
|
.stderr(std::process::Stdio::piped())
|
||||||
.stdout(std::process::Stdio::piped())
|
.stdout(std::process::Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| CodeError::ServerUnexpectedExit(format!("{}", e)))?;
|
.map_err(|e| CodeError::ServerUnexpectedExit(format!("{e}")))?;
|
||||||
|
|
||||||
self.server_paths
|
self.server_paths
|
||||||
.write_pid(child.id().expect("expected server to have pid"))?;
|
.write_pid(child.id().expect("expected server to have pid"))?;
|
||||||
@@ -677,7 +677,7 @@ where
|
|||||||
f.write_all(b"\n")?;
|
f.write_all(b"\n")?;
|
||||||
}
|
}
|
||||||
if write_directly {
|
if write_directly {
|
||||||
println!("{}", line);
|
println!("{line}");
|
||||||
} else {
|
} else {
|
||||||
trace!(plog, line);
|
trace!(plog, line);
|
||||||
}
|
}
|
||||||
@@ -732,7 +732,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_extensions_flag(extension_id: &str) -> String {
|
fn get_extensions_flag(extension_id: &str) -> String {
|
||||||
format!("--install-extension={}", extension_id)
|
format!("--install-extension={extension_id}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A type that can be used to scan stdout from the VS Code server. Returns
|
/// A type that can be used to scan stdout from the VS Code server. Returns
|
||||||
@@ -829,7 +829,7 @@ pub fn print_listening(log: &log::Logger, tunnel_name: &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let message = &format!("\nOpen this link in your browser {}\n", addr);
|
let message = &format!("\nOpen this link in your browser {addr}\n");
|
||||||
log.result(message);
|
log.result(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ async fn process_socket(
|
|||||||
{
|
{
|
||||||
debug!(log, "closing socket reader: {}", e);
|
debug!(log, "closing socket reader: {}", e);
|
||||||
socket_tx
|
socket_tx
|
||||||
.send(SocketSignal::CloseWith(CloseReason(format!("{}", e))))
|
.send(SocketSignal::CloseWith(CloseReason(format!("{e}"))))
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@@ -1192,7 +1192,7 @@ async fn handle_acquire_cli(
|
|||||||
|
|
||||||
let release = match params.commit_id {
|
let release = match params.commit_id {
|
||||||
Some(commit) => Release {
|
Some(commit) => Release {
|
||||||
name: format!("{} CLI", PRODUCT_NAME_LONG),
|
name: format!("{PRODUCT_NAME_LONG} CLI"),
|
||||||
commit,
|
commit,
|
||||||
platform: params.platform,
|
platform: params.platform,
|
||||||
quality: params.quality,
|
quality: params.quality,
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ mod tunnel_flags {
|
|||||||
flags |= IS_WSL_INSTALLED;
|
flags |= IS_WSL_INSTALLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
format!("_flag{}", flags)
|
format!("_flag{flags}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,8 +282,7 @@ fn get_host_token_from_tunnel(tunnel: &Tunnel) -> String {
|
|||||||
fn is_valid_name(name: &str) -> Result<(), InvalidTunnelName> {
|
fn is_valid_name(name: &str) -> Result<(), InvalidTunnelName> {
|
||||||
if name.len() > MAX_TUNNEL_NAME_LENGTH {
|
if name.len() > MAX_TUNNEL_NAME_LENGTH {
|
||||||
return Err(InvalidTunnelName(format!(
|
return Err(InvalidTunnelName(format!(
|
||||||
"Names cannot be longer than {} characters. Please try a different name.",
|
"Names cannot be longer than {MAX_TUNNEL_NAME_LENGTH} characters. Please try a different name."
|
||||||
MAX_TUNNEL_NAME_LENGTH
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,7 +616,7 @@ impl DevTunnels {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(AnyError::from(TunnelCreationFailed(
|
return Err(AnyError::from(TunnelCreationFailed(
|
||||||
name.to_string(),
|
name.to_string(),
|
||||||
format!("{:?}", e),
|
format!("{e:?}"),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
Ok(t) => break t,
|
Ok(t) => break t,
|
||||||
@@ -789,7 +788,7 @@ impl DevTunnels {
|
|||||||
let mut placeholder_name = Self::get_placeholder_name();
|
let mut placeholder_name = Self::get_placeholder_name();
|
||||||
if !is_name_free(&placeholder_name) {
|
if !is_name_free(&placeholder_name) {
|
||||||
for i in 2.. {
|
for i in 2.. {
|
||||||
let fixed_name = format!("{}{}", placeholder_name, i);
|
let fixed_name = format!("{placeholder_name}{i}");
|
||||||
if is_name_free(&fixed_name) {
|
if is_name_free(&fixed_name) {
|
||||||
placeholder_name = fixed_name;
|
placeholder_name = fixed_name;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ impl SleepInhibitor {
|
|||||||
return Err(wrap(
|
return Err(wrap(
|
||||||
e2,
|
e2,
|
||||||
format!(
|
format!(
|
||||||
"error requesting sleep inhibition, pminhibitor gave {}, screensaver gave",
|
"error requesting sleep inhibition, pminhibitor gave {e1}, screensaver gave"
|
||||||
e1
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.into());
|
.into());
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ impl ServerPaths {
|
|||||||
|
|
||||||
// VS Code Server pid
|
// VS Code Server pid
|
||||||
pub fn write_pid(&self, pid: u32) -> Result<(), WrappedError> {
|
pub fn write_pid(&self, pid: u32) -> Result<(), WrappedError> {
|
||||||
write(&self.pidfile, format!("{}", pid)).map_err(|e| {
|
write(&self.pidfile, format!("{pid}")).map_err(|e| {
|
||||||
wrap(
|
wrap(
|
||||||
e,
|
e,
|
||||||
format!("error writing process id into {}", self.pidfile.display()),
|
format!("error writing process id into {}", self.pidfile.display()),
|
||||||
@@ -155,5 +155,5 @@ pub fn get_all_servers(lp: &LauncherPaths) -> Vec<InstalledServer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_server_folder_name(quality: Quality, commit: &str) -> String {
|
pub fn get_server_folder_name(quality: Quality, commit: &str) -> String {
|
||||||
format!("{}-{}", quality, commit)
|
format!("{quality}-{commit}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ pub(crate) async fn tail_log_file(log_file: &Path) -> Result<(), AnyError> {
|
|||||||
let mut rx = tailf(file, 20);
|
let mut rx = tailf(file, 20);
|
||||||
while let Some(line) = rx.recv().await {
|
while let Some(line) = rx.recv().await {
|
||||||
match line {
|
match line {
|
||||||
TailEvent::Line(l) => print!("{}", l),
|
TailEvent::Line(l) => print!("{l}"),
|
||||||
TailEvent::Reset => println!("== Tunnel service restarted =="),
|
TailEvent::Reset => println!("== Tunnel service restarted =="),
|
||||||
TailEvent::Err(e) => return Err(wrap(e, "error reading log file").into()),
|
TailEvent::Err(e) => return Err(wrap(e, "error reading log file").into()),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ impl SystemdService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn service_name_string() -> String {
|
fn service_name_string() -> String {
|
||||||
format!("{}-tunnel.service", APPLICATION_NAME)
|
format!("{APPLICATION_NAME}-tunnel.service")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ impl fmt::Display for ShutdownSignal {
|
|||||||
match self {
|
match self {
|
||||||
ShutdownSignal::CtrlC => write!(f, "Ctrl-C received"),
|
ShutdownSignal::CtrlC => write!(f, "Ctrl-C received"),
|
||||||
ShutdownSignal::ParentProcessKilled(p) => {
|
ShutdownSignal::ParentProcessKilled(p) => {
|
||||||
write!(f, "Parent process {} no longer exists", p)
|
write!(f, "Parent process {p} no longer exists")
|
||||||
}
|
}
|
||||||
ShutdownSignal::ExeUninstalled => {
|
ShutdownSignal::ExeUninstalled => {
|
||||||
write!(f, "Executable no longer exists")
|
write!(f, "Executable no longer exists")
|
||||||
|
|||||||
@@ -239,7 +239,8 @@ impl BroadcastLogSink {
|
|||||||
|
|
||||||
fn replay_and_subscribe(
|
fn replay_and_subscribe(
|
||||||
&self,
|
&self,
|
||||||
) -> ConcatReceivable<Vec<u8>, mpsc::UnboundedReceiver<Vec<u8>>, broadcast::Receiver<Vec<u8>>> {
|
) -> ConcatReceivable<Vec<u8>, mpsc::UnboundedReceiver<Vec<u8>>, broadcast::Receiver<Vec<u8>>>
|
||||||
|
{
|
||||||
let (log_replay_tx, log_replay_rx) = mpsc::unbounded_channel();
|
let (log_replay_tx, log_replay_rx) = mpsc::unbounded_channel();
|
||||||
|
|
||||||
for log in self.recent.lock().unwrap().iter() {
|
for log in self.recent.lock().unwrap().iter() {
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ pub async fn kill_tree(process_id: u32) -> Result<(), CodeError> {
|
|||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| CodeError::CommandFailed {
|
.map_err(|e| CodeError::CommandFailed {
|
||||||
command: format!("pgrep -P {}", parent_id),
|
command: format!("pgrep -P {parent_id}"),
|
||||||
code: -1,
|
code: -1,
|
||||||
output: e.to_string(),
|
output: e.to_string(),
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ impl From<reqwest::Error> for WrappedError {
|
|||||||
"error requesting {}",
|
"error requesting {}",
|
||||||
e.url().map_or("<unknown>", |u| u.as_str())
|
e.url().map_or("<unknown>", |u| u.as_str())
|
||||||
),
|
),
|
||||||
original: format!("{}", e),
|
original: format!("{e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ where
|
|||||||
{
|
{
|
||||||
WrappedError {
|
WrappedError {
|
||||||
message: message.into(),
|
message: message.into(),
|
||||||
original: format!("{:?}", original),
|
original: format!("{original:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ where
|
|||||||
{
|
{
|
||||||
WrappedError {
|
WrappedError {
|
||||||
message: message.into(),
|
message: message.into(),
|
||||||
original: format!("{}", original),
|
original: format!("{original}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,10 +93,7 @@ impl StatusError {
|
|||||||
let body = res.text().await.map_err(|e| {
|
let body = res.text().await.map_err(|e| {
|
||||||
wrap(
|
wrap(
|
||||||
e,
|
e,
|
||||||
format!(
|
format!("failed to read response body on {status_code} code from {url}"),
|
||||||
"failed to read response body on {} code from {}",
|
|
||||||
status_code, url
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -290,7 +287,7 @@ pub struct CannotForwardControlPort();
|
|||||||
|
|
||||||
impl std::fmt::Display for CannotForwardControlPort {
|
impl std::fmt::Display for CannotForwardControlPort {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
write!(f, "Cannot forward or unforward port {}.", CONTROL_PORT)
|
write!(f, "Cannot forward or unforward port {CONTROL_PORT}.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +305,7 @@ pub struct ServiceAlreadyRegistered();
|
|||||||
|
|
||||||
impl std::fmt::Display for ServiceAlreadyRegistered {
|
impl std::fmt::Display for ServiceAlreadyRegistered {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
write!(f, "Already registered the service. Run `{} tunnel service uninstall` to unregister it first", APPLICATION_NAME)
|
write!(f, "Already registered the service. Run `{APPLICATION_NAME} tunnel service uninstall` to unregister it first")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +431,7 @@ impl Display for DbusConnectFailedError {
|
|||||||
str.push_str(&self.0);
|
str.push_str(&self.0);
|
||||||
str.push('\n');
|
str.push('\n');
|
||||||
|
|
||||||
write!(f, "{}", str)
|
write!(f, "{str}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ mod tests {
|
|||||||
let base_line = "Elit ipsum cillum ex cillum. Adipisicing consequat cupidatat do proident ut in sunt Lorem ipsum tempor. Eiusmod ipsum Lorem labore exercitation sunt pariatur excepteur fugiat cillum velit cillum enim. Nisi Lorem cupidatat ad enim velit officia eiusmod esse tempor aliquip. Deserunt pariatur tempor in duis culpa esse sit nulla irure ullamco ipsum voluptate non laboris. Occaecat officia nulla officia mollit do aliquip reprehenderit ad incididunt.";
|
let base_line = "Elit ipsum cillum ex cillum. Adipisicing consequat cupidatat do proident ut in sunt Lorem ipsum tempor. Eiusmod ipsum Lorem labore exercitation sunt pariatur excepteur fugiat cillum velit cillum enim. Nisi Lorem cupidatat ad enim velit officia eiusmod esse tempor aliquip. Deserunt pariatur tempor in duis culpa esse sit nulla irure ullamco ipsum voluptate non laboris. Occaecat officia nulla officia mollit do aliquip reprehenderit ad incididunt.";
|
||||||
for i in 0..100 {
|
for i in 0..100 {
|
||||||
let line = format!("{}: {}", i, &base_line[..rng.gen_range(0..base_line.len())]);
|
let line = format!("{}: {}", i, &base_line[..rng.gen_range(0..base_line.len())]);
|
||||||
writeln!(&mut read_file, "{}", line).unwrap();
|
writeln!(&mut read_file, "{line}").unwrap();
|
||||||
written.push(line);
|
written.push(line);
|
||||||
}
|
}
|
||||||
write!(&mut read_file, "partial line").unwrap();
|
write!(&mut read_file, "partial line").unwrap();
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ impl PreReqChecker {
|
|||||||
|
|
||||||
let bullets = errors
|
let bullets = errors
|
||||||
.iter()
|
.iter()
|
||||||
.map(|e| format!(" - {}", e))
|
.map(|e| format!(" - {e}"))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
@@ -142,8 +142,7 @@ async fn check_musl_interpreter() -> Result<(), String> {
|
|||||||
|
|
||||||
if fs::metadata(MUSL_PATH).await.is_err() {
|
if fs::metadata(MUSL_PATH).await.is_err() {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"find {}, which is required to run the {} in musl environments",
|
"find {MUSL_PATH}, which is required to run the {QUALITYLESS_SERVER_NAME} in musl environments"
|
||||||
MUSL_PATH, QUALITYLESS_SERVER_NAME
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,8 +230,7 @@ async fn check_glibcxx_version() -> Result<bool, String> {
|
|||||||
Some(path) => match fs::read(&path).await {
|
Some(path) => match fs::read(&path).await {
|
||||||
Ok(contents) => check_for_sufficient_glibcxx_versions(contents),
|
Ok(contents) => check_for_sufficient_glibcxx_versions(contents),
|
||||||
Err(e) => Err(format!(
|
Err(e) => Err(format!(
|
||||||
"validate GLIBCXX version for GNU environments, but could not: {}",
|
"validate GLIBCXX version for GNU environments, but could not: {e}"
|
||||||
e
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
None => Err("find libstdc++.so or ldconfig for GNU environments".to_owned()),
|
None => Err("find libstdc++.so or ldconfig for GNU environments".to_owned()),
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ where
|
|||||||
}
|
}
|
||||||
let mut file = archive
|
let mut file = archive
|
||||||
.by_index(i)
|
.by_index(i)
|
||||||
.map_err(|e| wrap(e, format!("could not open zip entry {}", i)))?;
|
.map_err(|e| wrap(e, format!("could not open zip entry {i}")))?;
|
||||||
|
|
||||||
let outpath: PathBuf = match file.enclosed_name() {
|
let outpath: PathBuf = match file.enclosed_name() {
|
||||||
Some(path) => {
|
Some(path) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user