Skip to content

Commit

Permalink
Add package name to help text
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte committed Apr 11, 2019
1 parent 9ed84bb commit 8ba6f6a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ crate fn run(args: &cli::BuildArgs) -> Result<CargoArtifact, SubcommandError> {
}

fn split_output(json: &str) -> (Vec<&str>, Vec<&str>) {
json
.trim()
json.trim()
.split('\n')
.filter(|x| x.find(r#""reason":"build-script-executed""#).is_none())
.partition(|x| x.find(r#""reason":"compiler-artifact""#).is_some())
Expand Down
16 changes: 13 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,28 @@ crate fn parse_args() -> Result<Args, ArgParseError> {
// Process common arguments
for arg in args {
if arg == "--help" || arg == "-h" {
eprintln!(include_str!("templates/help.fmt"), target);
eprintln!(
include_str!("templates/help.fmt"),
env!("CARGO_PKG_NAME"),
target
);
process::exit(0);
} else if arg == "--version" || arg == "-V" {
eprintln!("Version {}", env!("CARGO_PKG_VERSION"));
eprintln!(
"{}\nVersion {}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION")
);
process::exit(0);
} else {
rest.push(arg.to_owned());
}
}

// Check subcommand after handling --help and --version
if let Subcommand::None = subcommand { Err(MissingSubcommand)? }
if let Subcommand::None = subcommand {
Err(MissingSubcommand)?
}

Ok(Args {
subcommand,
Expand Down
1 change: 1 addition & 0 deletions src/templates/help.fmt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{}
Nintendo 64 build tool

USAGE:
Expand Down

0 comments on commit 8ba6f6a

Please sign in to comment.