Add List function
This commit is contained in:
21
src/app.rs
21
src/app.rs
@@ -47,6 +47,8 @@ enum Subcommand {
|
||||
#[clap(subcommand)]
|
||||
command: UtilSubcommand,
|
||||
},
|
||||
/// List available build modes
|
||||
List,
|
||||
}
|
||||
|
||||
#[derive(clap::Subcommand)]
|
||||
@@ -143,10 +145,29 @@ impl App {
|
||||
}
|
||||
}
|
||||
},
|
||||
Subcommand::List => match list() {
|
||||
Err(e) => {
|
||||
eprintln!("Error listing build profiles: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn list() -> std::io::Result<()> {
|
||||
let conf = get_config().ok_or(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
"no Pallet.toml found in local directory",
|
||||
))?;
|
||||
for build in conf.build {
|
||||
println!(" - {}: {:?}", build.name.green().bold(), build.args);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn create_project<P: AsRef<Path>>(directory: P) -> std::io::Result<()> {
|
||||
let name = if directory.as_ref().to_string_lossy() == "." {
|
||||
String::new()
|
||||
|
||||
Reference in New Issue
Block a user