mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 21:06:48 +00:00
Subcommand new
should not parse CommonArgs
This commit is contained in:
parent
1391ff59f2
commit
3b95191f7e
@ -22,6 +22,9 @@ Use the kernel template.
|
||||
If this option is not set,
|
||||
the library template will be used by default.
|
||||
|
||||
`--library`:
|
||||
Use the library template. This is the default option.
|
||||
|
||||
## Examples
|
||||
|
||||
- Create a new kernel named `myos`:
|
||||
|
@ -18,32 +18,34 @@ use crate::{
|
||||
};
|
||||
|
||||
pub fn main() {
|
||||
let (osdk_subcommand, common_args) = match Cli::parse() {
|
||||
Cli {
|
||||
cargo_subcommand: CargoSubcommand::Osdk(osdk_subcommand),
|
||||
common_args,
|
||||
} => (osdk_subcommand, common_args),
|
||||
};
|
||||
|
||||
let load_config = || {
|
||||
let load_config = |common_args: &CommonArgs| {
|
||||
let manifest = TomlManifest::load();
|
||||
let scheme = manifest.get_scheme(common_args.scheme.as_ref());
|
||||
Config::new(scheme, &common_args)
|
||||
Config::new(scheme, common_args)
|
||||
};
|
||||
|
||||
match &osdk_subcommand {
|
||||
let cli = Cli::parse();
|
||||
let CargoSubcommand::Osdk(osdk_subcommand) = &cli.cargo_subcommand;
|
||||
|
||||
match osdk_subcommand {
|
||||
OsdkSubcommand::New(args) => execute_new_command(args),
|
||||
OsdkSubcommand::Build(build_args) => {
|
||||
execute_build_command(&load_config(), build_args);
|
||||
execute_build_command(&load_config(&build_args.common_args), build_args);
|
||||
}
|
||||
OsdkSubcommand::Run(run_args) => {
|
||||
execute_run_command(&load_config(), &run_args.gdb_server_args);
|
||||
execute_run_command(
|
||||
&load_config(&run_args.common_args),
|
||||
&run_args.gdb_server_args,
|
||||
);
|
||||
}
|
||||
OsdkSubcommand::Debug(debug_args) => {
|
||||
execute_debug_command(&load_config().run.build.profile, debug_args);
|
||||
execute_debug_command(
|
||||
&load_config(&debug_args.common_args).run.build.profile,
|
||||
debug_args,
|
||||
);
|
||||
}
|
||||
OsdkSubcommand::Test(test_args) => {
|
||||
execute_test_command(&load_config(), test_args);
|
||||
execute_test_command(&load_config(&test_args.common_args), test_args);
|
||||
}
|
||||
OsdkSubcommand::Check(args) => execute_forwarded_command("check", &args.args),
|
||||
OsdkSubcommand::Clippy(args) => execute_forwarded_command("clippy", &args.args),
|
||||
@ -57,8 +59,6 @@ pub fn main() {
|
||||
pub struct Cli {
|
||||
#[clap(subcommand)]
|
||||
cargo_subcommand: CargoSubcommand,
|
||||
#[command(flatten)]
|
||||
common_args: CommonArgs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
@ -154,12 +154,16 @@ pub struct BuildArgs {
|
||||
value_name = "DIR"
|
||||
)]
|
||||
pub output: Option<PathBuf>,
|
||||
#[command(flatten)]
|
||||
pub common_args: CommonArgs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct RunArgs {
|
||||
#[command(flatten)]
|
||||
pub gdb_server_args: GdbServerArgs,
|
||||
#[command(flatten)]
|
||||
pub common_args: CommonArgs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args, Clone, Default)]
|
||||
@ -197,6 +201,8 @@ pub struct DebugArgs {
|
||||
default_value = ".aster-gdb-socket"
|
||||
)]
|
||||
pub remote: String,
|
||||
#[command(flatten)]
|
||||
pub common_args: CommonArgs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
@ -206,6 +212,8 @@ pub struct TestArgs {
|
||||
help = "Only run tests containing this string in their names"
|
||||
)]
|
||||
pub test_name: Option<String>,
|
||||
#[command(flatten)]
|
||||
pub common_args: CommonArgs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args, Default, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
@ -255,6 +263,7 @@ impl CargoArgs {
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
/// Common args used for build, run, test and debug subcommand
|
||||
pub struct CommonArgs {
|
||||
#[command(flatten)]
|
||||
pub build_args: CargoArgs,
|
||||
|
@ -6,7 +6,7 @@ use crate::util::*;
|
||||
fn cli_help_message() {
|
||||
let output = cargo_osdk(&["-h"]).output().unwrap();
|
||||
assert_success(&output);
|
||||
assert_stdout_contains_msg(&output, "cargo osdk [OPTIONS] <COMMAND>");
|
||||
assert_stdout_contains_msg(&output, "cargo osdk <COMMAND>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user