This commit is contained in:
parent
a191ece9a5
commit
422330d195
|
@ -39,26 +39,28 @@ enum CliCommand {
|
|||
/// # use fayalite::{hdl_module};
|
||||
/// # #[hdl_module]
|
||||
/// # fn my_module() {}
|
||||
/// use clap::{Subcommand, Parser};
|
||||
///
|
||||
/// #[derive(clap::Subcommand)]
|
||||
/// pub enum Subcommand {
|
||||
/// #[derive(Subcommand)]
|
||||
/// pub enum Cmd {
|
||||
/// #[command(flatten)]
|
||||
/// Fayalite(fayalite::cli::Cli),
|
||||
/// MySpecialCommand {
|
||||
/// #[arg]
|
||||
/// #[arg(long)]
|
||||
/// foo: bool,
|
||||
/// },
|
||||
/// }
|
||||
///
|
||||
/// #[derive(clap::Parser)]
|
||||
/// #[derive(Parser)]
|
||||
/// pub struct Cli {
|
||||
/// #[command(subcommand)]
|
||||
/// subcommand: Subcommand, // or just use fayalite::cli::Cli directly
|
||||
/// cmd: Cmd, // or just use fayalite::cli::Cli directly
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// match Cli::parse().subcommand {
|
||||
/// Subcommand::Fayalite(v) => v.run(my_module()),
|
||||
/// Subcommand::MySpecialCommand { foo } => println!("special: foo={foo}"),
|
||||
/// match Cli::parse().cmd {
|
||||
/// Cmd::Fayalite(v) => v.run(my_module()),
|
||||
/// Cmd::MySpecialCommand { foo } => println!("special: foo={foo}"),
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
|
|
Loading…
Reference in a new issue