Skip to content

Commit

Permalink
Merge pull request #290 from boozook/fix-device-query-env
Browse files Browse the repository at this point in the history
Fix `device` (query) env var implicitly sets `device` arg as set, but have to be just value (#279)
  • Loading branch information
boozook authored Apr 12, 2024
2 parents 0046a7d + 61c6fb0 commit 9ba6ab3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-playdate"
version = "0.4.0"
version = "0.4.1"
readme = "README.md"
description = "Build tool for neat yellow console."
keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"]
Expand Down
23 changes: 22 additions & 1 deletion cargo/src/cli/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use cargo::util::command_prelude::{CommandExt, flag, opt, multi_opt};
use clap::builder::{Str, ArgPredicate};
use clap::{Arg, ArgAction, value_parser, Args};
use clap::Command;
use device::device::query::DEVICE_SERIAL_ENV;
use playdate::consts::{SDK_ENV_VAR, DEVICE_TARGET};
use playdate::toolchain::gcc::ARM_GCC_PATH_ENV_VAR;

Expand Down Expand Up @@ -237,7 +238,27 @@ pub struct Mount {

fn mount() -> Vec<Arg> {
let mount: Command =
Mount::augment_args(Command::new("mount")).mut_arg("device", |arg| arg.long("device").num_args(0..=1));
Mount::augment_args(Command::new("mount")).mut_arg("device", |arg| {
let env = std::env::var_os(DEVICE_SERIAL_ENV);
let arg = arg.long("device").num_args(0..=1);
if let Some(value) = env {
let help_env = {
let s = value.to_string_lossy();
format!("[env: {DEVICE_SERIAL_ENV}={s}]",)
};

let help_arg = {
let help = arg.get_help().unwrap_or_default();
format!("{help} {help_env}")
};
arg.env(format!("{DEVICE_SERIAL_ENV}_SET"))
.hide_env(true)
.default_missing_value(value)
.help(help_arg)
} else {
arg
}
});
mount.get_arguments()
.cloned()
.map(|arg| arg.group("mounting"))
Expand Down

0 comments on commit 9ba6ab3

Please sign in to comment.