Skip to content

Commit

Permalink
Propagate introspection options.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeMathWalker committed Apr 28, 2024
1 parent c4c804e commit f182757
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
32 changes: 25 additions & 7 deletions libs/pavex_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ fn main() -> Result<ExitCode, miette::Error> {
init_miette_hook(&cli);
let _guard = init_telemetry(cli.log_filter, cli.log, cli.perf_profile);

let mut client = Client::new().color(cli.color.into());
if cli.debug {
client = client.debug();
} else {
client = client.no_debug();
}

let client = pavexc_client(&cli);
let system_home_dir = xdg_home::home_dir().ok_or_else(|| {
miette::miette!("Failed to get the system home directory from the environment")
})?;
Expand Down Expand Up @@ -103,6 +97,30 @@ fn main() -> Result<ExitCode, miette::Error> {
.map_err(utils::anyhow2miette)
}

/// Propagate introspection options from `pavex` to pavexc`.
fn pavexc_client(cli: &Cli) -> Client {
let mut client = Client::new().color(cli.color.into());
if cli.debug {
client = client.debug();
} else {
client = client.no_debug();
}
if cli.log {
client = client.log();
} else {
client = client.no_log();
}
if cli.perf_profile {
client = client.perf_profile();
} else {
client = client.no_perf_profile();
}
if let Some(log_filter) = &cli.log_filter {
client = client.log_filter(log_filter.to_owned());
}
client
}

#[tracing::instrument("Generate server sdk", skip(client, locator, shell))]
fn generate(
shell: &mut Shell,
Expand Down
2 changes: 1 addition & 1 deletion libs/pavex_cli_client/src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl GenerateBuilder {
///
/// This method can be useful if you need to customize the command before running it.
/// If that's not your usecase, consider using [`GenerateBuilder::execute`] instead.
pub fn command(mut self) -> Result<std::process::Command, BlueprintPersistenceError> {
pub fn command(mut self) -> Result<Command, BlueprintPersistenceError> {
// TODO: Pass the blueprint via `stdin` instead of writing it to a file.
let bp_path = self.output_directory.join("blueprint.ron");
self.blueprint
Expand Down

0 comments on commit f182757

Please sign in to comment.