Multiple ways to specify OSDK new's type

This commit is contained in:
Zhang Junyang
2024-03-25 23:01:12 +08:00
committed by Tate, Hongliang Tian
parent dcab4e1039
commit 3dce753c86
12 changed files with 58 additions and 20 deletions

View File

@ -97,16 +97,43 @@ pub struct ForwardedArguments {
#[derive(Debug, Parser)]
pub struct NewArgs {
#[arg(
id = "type",
long = "type",
short = 't',
default_value = "library",
help = "The type of the project to create"
help = "The type of the project to create",
conflicts_with_all = ["kernel", "library"],
)]
pub type_: ProjectType,
#[arg(
long,
help = "Create a kernel package",
conflicts_with_all = ["library", "type"],
)]
pub kernel: bool,
#[arg(
long,
alias = "lib",
help = "Create a library package",
conflicts_with_all = ["kernel", "type"],
)]
pub library: bool,
#[arg(name = "name", required = true)]
pub crate_name: String,
}
impl NewArgs {
pub fn project_type(&self) -> ProjectType {
if self.kernel {
ProjectType::Kernel
} else if self.library {
ProjectType::Library
} else {
self.type_
}
}
}
#[derive(Debug, Parser)]
pub struct BuildArgs {
#[command(flatten)]