diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 13d95f0..09bc894 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,7 +1,16 @@ -use clap::{ValueEnum, Parser, AppSettings}; +use clap::{AppSettings, Parser, ValueEnum}; use std::fmt::{Display, Formatter}; #[derive(Parser)] +#[clap(name = "cargo")] +#[clap(bin_name = "cargo")] +pub enum Cargo { + #[clap(name = "3ds")] + Input(Input), +} + +#[derive(clap::Args)] +#[clap(about)] #[clap(global_setting(AppSettings::AllowLeadingHyphen))] pub struct Input { #[clap(value_enum)] diff --git a/src/lib.rs b/src/lib.rs index 0046f5a..d2279ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,6 +29,9 @@ pub fn build_elf( stdout_reader = BufReader::new(command_stdout); &mut stdout_reader } else { + // The user presumably cares about the message format, so we should + // copy stuff to stdout like they expect. We can still extract the executable + // information out of it that we need for 3dsxtool etc. tee_reader = BufReader::new(TeeReader::new(command_stdout, io::stdout())); &mut tee_reader }; @@ -59,8 +62,6 @@ fn make_cargo_build_command( command.arg("-Z").arg("build-std"); } - println!("{:?}", args); - command .env("RUSTFLAGS", rust_flags) .arg(&cmd.to_string()) diff --git a/src/main.rs b/src/main.rs index 415b5a0..6897aaa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,12 @@ -use cargo_3ds::commands::{CargoCommand, Input}; +use cargo_3ds::commands::{Cargo, CargoCommand}; use cargo_3ds::{build_3dsx, build_elf, build_smdh, check_rust_version, get_metadata, link}; -use clap::{Parser}; +use clap::Parser; use std::process; fn main() { check_rust_version(); - let mut input: Input = Input::parse(); + let Cargo::Input(mut input) = Cargo::parse(); let should_link = input.cmd == CargoCommand::Build || (input.cmd == CargoCommand::Test @@ -17,16 +17,16 @@ fn main() { true }); - let message_format = if let Some(pos) = input.cargo_opts + let message_format = if let Some(pos) = input + .cargo_opts .iter() .position(|s| s.starts_with("--message-format")) { let arg = input.cargo_opts.remove(pos); - let format = if let Some((_, format)) = arg.split_once('=') - { + let format = if let Some((_, format)) = arg.split_once('=') { format.to_string() } else { - input.cargo_opts.remove(pos).to_string() + input.cargo_opts.remove(pos) }; if !format.starts_with("json") { eprintln!("error: non-JSON `message-format` is not supported");