Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Nov 12, 2024
1 parent 0109605 commit ee7564b
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 53 deletions.
6 changes: 4 additions & 2 deletions src/cli/directory_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ fn _check() -> anyhow::Result<Option<PathBuf>> {
pub fn check_and_error() -> anyhow::Result<()> {
match _check().context("failed directory check")? {
Some(dir) => {
print::error!("{BRANDING_CLI} no longer uses `{dir}` to store data \
print::error!(
"{BRANDING_CLI} no longer uses `{dir}` to store data \
and now uses standard locations of your OS.",
dir = dir.display());
dir = dir.display()
);
print_markdown!(
"To upgrade the directory layout, run: \n\
```\n\
Expand Down
6 changes: 4 additions & 2 deletions src/cloud/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ pub fn logout(c: &options::Logout, options: &CloudOptions) -> anyhow::Result<()>
}
skipped = !removed;
} else {
print::warn!("Already logged out from {BRANDING_CLOUD} for profile \"{}\".",
client.profile.as_deref().unwrap_or("default"));
print::warn!(
"Already logged out from {BRANDING_CLOUD} for profile \"{}\".",
client.profile.as_deref().unwrap_or("default")
);
}
}
if !warnings.is_empty() {
Expand Down
4 changes: 1 addition & 3 deletions src/commands/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ pub async fn common(
Some(addr) => {
println!("{}", addr.0);
}
None => print::error!(
"pgaddr requires {BRANDING} to run in DEV mode"
),
None => print::error!("pgaddr requires {BRANDING} to run in DEV mode"),
}
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/commands/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ fn _get_local_ui_url(cmd: &UI, cfg: &edgedb_tokio::Config) -> anyhow::Result<Str
match open_url(&url).map(|r| r.status()) {
Ok(reqwest::StatusCode::OK) => {}
Ok(reqwest::StatusCode::NOT_FOUND) => {
print::error!(
"Web UI not served correctly by specified {BRANDING} server."
);
print::error!("Web UI not served correctly by specified {BRANDING} server.");
msg!(
" Try running the \
server with `--admin-ui=enabled`."
Expand All @@ -123,8 +121,10 @@ fn _get_local_ui_url(cmd: &UI, cfg: &edgedb_tokio::Config) -> anyhow::Result<Str
}
Ok(status) => {
log::info!("GET {} returned status code {}", url, status);
print::error!("Web UI not served correctly by specified {BRANDING} server. \
Try `edgedb instance logs -I <instance_name>` to see details.");
print::error!(
"Web UI not served correctly by specified {BRANDING} server. \
Try `edgedb instance logs -I <instance_name>` to see details."
);
return Err(ExitCode::new(3).into());
}
Err(e) => {
Expand Down
3 changes: 1 addition & 2 deletions src/migrations/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ pub async fn extract(
let to_migrations_dir = src_ctx.schema_dir.join("migrations");
if !to_migrations_dir.is_dir() {
if src_ctx.schema_dir.is_dir() {
print::warn!("Creating directory {}",
to_migrations_dir.display());
print::warn!("Creating directory {}", to_migrations_dir.display());
fs::create_dir(to_migrations_dir)?;
} else {
anyhow::bail!(
Expand Down
12 changes: 8 additions & 4 deletions src/migrations/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,25 @@ pub async fn migrations_applied(
iter.next(); // skip db_migration itself
let first = iter.next().unwrap(); // we know it's not last
let count = iter.count() + 1;
print::error!("Database is at migration {db:?} while sources \
print::error!(
"Database is at migration {db:?} while sources \
contain {n} migrations ahead, \
starting from {first:?}({first_file})",
db = db_migration,
n = count,
first = first,
first_file = migrations[first].path.display());
first_file = migrations[first].path.display()
);
} else {
print::error!("Database revision {db_migration} not found in the filesystem.");
eprintln!(" Consider updating sources.");
}
} else {
print::error!("Database is empty, while {} migrations \
print::error!(
"Database is empty, while {} migrations \
have been found in the filesystem.",
migrations.len());
migrations.len()
);
eprintln!(" Run `{BRANDING_CLI_CMD} migrate` to apply.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/migrations/upgrade_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::portable::config::Config;
use crate::portable::install;
use crate::portable::local::InstallInfo;
use crate::portable::repository::{self, PackageInfo, Query};
use crate::print::{msg, success, self, Highlight};
use crate::print::{self, msg, success, Highlight};
use crate::process;
use crate::watch::wait_changes;

Expand Down
6 changes: 4 additions & 2 deletions src/non_interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ pub async fn noninteractive_main(q: &Query, options: &Options) -> Result<(), any
run_query(&mut conn, query, options, fmt).await?;
}
} else {
print::error!("either a --file option or \
a <queries> positional argument is required.");
print::error!(
"either a --file option or \
a <queries> positional argument is required."
);
}

Ok(())
Expand Down
8 changes: 2 additions & 6 deletions src/portable/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ pub fn start(options: &Start) -> anyhow::Result<()> {
}
}
InstanceName::Cloud { .. } => {
print::error!(
"Starting {BRANDING_CLOUD} instances is not yet supported."
);
print::error!("Starting {BRANDING_CLOUD} instances is not yet supported.");
return Err(ExitCode::new(1))?;
}
};
Expand Down Expand Up @@ -415,9 +413,7 @@ pub fn stop(options: &Stop) -> anyhow::Result<()> {
}
}
InstanceName::Cloud { .. } => {
print::error!(
"Stopping {BRANDING_CLOUD} instances is not yet supported."
);
print::error!("Stopping {BRANDING_CLOUD} instances is not yet supported.");
return Err(ExitCode::new(1))?;
}
};
Expand Down
12 changes: 8 additions & 4 deletions src/portable/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ pub fn create(cmd: &Create, opts: &crate::options::Options) -> anyhow::Result<()
Err(ExitCode::new(exit_codes::DOCKER_CONTAINER))?;
}
if cmd.start_conf.is_some() {
print::warn!("The option `--start-conf` is deprecated. \
print::warn!(
"The option `--start-conf` is deprecated. \
Use `edgedb instance start/stop` to control \
the instance.");
the instance."
);
}

let mut client = cloud::client::CloudClient::new(&opts.cloud_options)?;
Expand Down Expand Up @@ -185,8 +187,10 @@ pub fn create(cmd: &Create, opts: &crate::options::Options) -> anyhow::Result<()
Ok(()) => {}
Err(e) => {
log::warn!("Error running {BRANDING} as a service: {e:#}");
print::warn!("{BRANDING} will not start on next login. \
Trying to start database in the background...");
print::warn!(
"{BRANDING} will not start on next login. \
Trying to start database in the background..."
);
control::start(&Start {
name: None,
instance: Some(inst_name),
Expand Down
6 changes: 4 additions & 2 deletions src/portable/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,10 @@ pub fn link(cmd: &Link, opts: &Options) -> anyhow::Result<()> {
.default(&default)
.ask()?;
if !is_valid_local_instance_name(&name) {
print::error!("Instance name must be a valid identifier, \
(regex: ^[a-zA-Z_0-9]+(-[a-zA-Z_0-9]+)*$)");
print::error!(
"Instance name must be a valid identifier, \
(regex: ^[a-zA-Z_0-9]+(-[a-zA-Z_0-9]+)*$)"
);
continue;
}
break (credentials::path(&name)?, name);
Expand Down
4 changes: 1 addition & 3 deletions src/portable/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,7 @@ pub fn logs(options: &Logs) -> anyhow::Result<()> {
let name = match instance_arg(&options.name, &options.instance)? {
InstanceName::Local(name) => name,
InstanceName::Cloud { .. } => {
print::error!(
"This operation is not yet supported on {BRANDING_CLOUD} instances."
);
print::error!("This operation is not yet supported on {BRANDING_CLOUD} instances.");
return Err(ExitCode::new(1))?;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/portable/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::portable::local::{
};
use crate::portable::repository::Channel;
use crate::portable::ver;
use crate::print::{err_marker, msg, self};
use crate::print::{self, err_marker, msg};
use crate::process::{self, IntoArg};

const DOMAIN_LABEL_MAX_LENGTH: usize = 63;
Expand Down
30 changes: 20 additions & 10 deletions src/portable/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,11 @@ pub fn init(options: &Init, opts: &crate::options::Options) -> anyhow::Result<()
}

if options.server_start_conf.is_some() {
print::warn!("The option `--server-start-conf` is deprecated. \
print::warn!(
"The option `--server-start-conf` is deprecated. \
Use `edgedb instance start/stop` to control \
the instance.");
the instance."
);
}

let Some((project_dir, config_path)) = project_dir(options.project_dir.as_deref())? else {
Expand Down Expand Up @@ -836,8 +838,10 @@ fn do_init(
Ok(()) => {}
Err(e) => {
log::warn!("Error running {BRANDING} as a service: {e:#}");
print::warn!("{BRANDING} will not start on next login. \
Trying to start database in the background...");
print::warn!(
"{BRANDING} will not start on next login. \
Trying to start database in the background..."
);
control::start(&Start {
name: None,
instance: Some(inst_name.clone()),
Expand Down Expand Up @@ -1373,10 +1377,12 @@ impl Handle<'_> {
match self.get_version() {
Ok(inst_ver) if ver_query.matches(&inst_ver) => {}
Ok(inst_ver) => {
print::warn!("WARNING: existing instance has version {}, \
print::warn!(
"WARNING: existing instance has version {}, \
but {} is required by {CONFIG_FILE_DISPLAY_NAME}",
inst_ver,
ver_query.display());
ver_query.display()
);
}
Err(e) => {
log::warn!("Could not check instance's version: {:#}", e);
Expand Down Expand Up @@ -1829,9 +1835,11 @@ pub fn find_project_stash_dirs(
}

pub fn print_instance_in_use_warning(name: &str, project_dirs: &[PathBuf]) {
print::warn!("Instance {:?} is used by the following project{}:",
print::warn!(
"Instance {:?} is used by the following project{}:",
name,
if project_dirs.len() > 1 { "s" } else { "" });
if project_dirs.len() > 1 { "s" } else { "" }
);
for dir in project_dirs {
let dest = match read_project_path(dir) {
Ok(path) => path,
Expand Down Expand Up @@ -1965,8 +1973,10 @@ fn print_other_project_warning(
}
}
if !project_dirs.is_empty() {
print::warn!("Warning: the instance {name} is still used by the following \
projects:");
print::warn!(
"Warning: the instance {name} is still used by the following \
projects:"
);
for pd in &project_dirs {
eprintln!(" {}", pd.display());
}
Expand Down
4 changes: 1 addition & 3 deletions src/portable/reset_password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ pub fn reset_password(options: &ResetPassword) -> anyhow::Result<()> {
}
}
InstanceName::Cloud { .. } => {
print::error!(
"This operation is not yet supported on {BRANDING_CLOUD} instances."
);
print::error!("This operation is not yet supported on {BRANDING_CLOUD} instances.");
return Err(ExitCode::new(1))?;
}
};
Expand Down
4 changes: 1 addition & 3 deletions src/portable/revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ pub fn revert(options: &Revert) -> anyhow::Result<()> {
}
}
InstanceName::Cloud { .. } => {
print::error!(
"This operation is not yet supported on {BRANDING_CLOUD} instances."
);
print::error!("This operation is not yet supported on {BRANDING_CLOUD} instances.");
return Err(ExitCode::new(1))?;
}
};
Expand Down

0 comments on commit ee7564b

Please sign in to comment.