Share one options between two values #2465
-
How can i add build-mode option like use clap::{AppSettings, Clap};
#[derive(Clap, Debug)]
#[clap(version = "0.1.0", author = "remimimimi <valent.xarin@gmail.com>")]
#[clap(setting = AppSettings::ColoredHelp)]
pub struct Args {
/// The target for which the kernel will be assembled
// #[clap(long, default_value = "riscv64gc-unknown-none-elf")]
#[clap(arg_enum, long, default_value = "riscv64gc-unknown-none-elf")]
target: Target,
#[clap(subcommand)]
subcommand: Command,
}
#[derive(Clap, Debug)]
#[clap(rename_all = "kebab_case")]
pub enum Target {
Riscv64gcUnknownNoneElf,
}
#[derive(Clap, Debug)]
pub enum Command {
/// Run kernel with emulator
Run(Run),
/// Build kernel
Build(Build),
}
#[derive(Clap, Debug)]
#[clap(setting = AppSettings::ColoredHelp)]
pub struct Run {
/// Command to run hak.elf kernel file, usually this is
/// qemu qemulator command for choosen target
#[clap(
short,
long,
default_value = "qemu-system-riscv64 -machine virt -cpu rv64 -smp 4 -m 128M -drive \
if=none,format=raw,file=hdd.dsk,id=foo -device virtio-blk-device,scsi=off,drive=foo \
-nographic -serial mon:stdio -bios none -device virtio-rng-device -device virtio-gpu-device \
-device virtio-net-device -device virtio-tablet-device -device virtio-keyboard-device \
-kernel "
)]
runner: String,
}
#[derive(Clap, Debug)]
#[clap(setting = AppSettings::ColoredHelp)]
pub struct Build {} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Are you asking about hiding the options? If yes, there's
But this line confused me about what exactly you want. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/clap-rs/clap/blob/master/clap_derive/examples/flatten.rs |
Beta Was this translation helpful? Give feedback.
https://github.com/clap-rs/clap/blob/master/clap_derive/examples/flatten.rs