Enforce ordering of commands/sub-commands according to source
By default, clap orders command alphabetically, which can be quite confusing when listing commands with `--help`: ``` SUBCOMMANDS: eval Evaluate an Untyped Plutus Core program flat Encode textual Untyped Plutus Core to flat bytes fmt Format an Untyped Plutus Core program help Print this message or the help of the given subcommand(s) unflat Decode flat bytes to textual Untyped Plutus Cor ``` It is possible to instrument clap to order commands in the same way they are declared in the source, giving us back the freedom to order and group them in a manner that makes sense, e.g.: ``` SUBCOMMANDS: fmt Format an Untyped Plutus Core program eval Evaluate an Untyped Plutus Core program flat Encode textual Untyped Plutus Core to flat bytes unflat Decode flat bytes to textual Untyped Plutus Cor help Print this message or the help of the given subcommand(s) ```
This commit is contained in:
parent
9c608ad9f1
commit
8d45b2a2f5
|
@ -4,6 +4,7 @@ use clap::Subcommand;
|
||||||
|
|
||||||
/// Commands for working with transactions
|
/// Commands for working with transactions
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
|
#[clap(setting(clap::AppSettings::DeriveDisplayOrder))]
|
||||||
pub enum Cmd {
|
pub enum Cmd {
|
||||||
Simulate(simulate::Args),
|
Simulate(simulate::Args),
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use clap::Subcommand;
|
||||||
|
|
||||||
/// Commands for working with untyped Plutus-core
|
/// Commands for working with untyped Plutus-core
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
|
#[clap(setting(clap::AppSettings::DeriveDisplayOrder))]
|
||||||
pub enum Cmd {
|
pub enum Cmd {
|
||||||
Fmt(fmt::Args),
|
Fmt(fmt::Args),
|
||||||
Eval(eval::Args),
|
Eval(eval::Args),
|
||||||
|
|
|
@ -7,6 +7,7 @@ use cmd::{build, check, new, tx, uplc};
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(version, about, long_about = None)]
|
#[clap(version, about, long_about = None)]
|
||||||
#[clap(propagate_version = true)]
|
#[clap(propagate_version = true)]
|
||||||
|
#[clap(setting(clap::AppSettings::DeriveDisplayOrder))]
|
||||||
pub enum Cmd {
|
pub enum Cmd {
|
||||||
New(new::Args),
|
New(new::Args),
|
||||||
Build(build::Args),
|
Build(build::Args),
|
||||||
|
@ -28,9 +29,9 @@ impl Default for Cmd {
|
||||||
fn main() -> miette::Result<()> {
|
fn main() -> miette::Result<()> {
|
||||||
miette::set_panic_hook();
|
miette::set_panic_hook();
|
||||||
match Cmd::default() {
|
match Cmd::default() {
|
||||||
|
Cmd::New(args) => new::exec(args),
|
||||||
Cmd::Build(args) => build::exec(args),
|
Cmd::Build(args) => build::exec(args),
|
||||||
Cmd::Check(args) => check::exec(args),
|
Cmd::Check(args) => check::exec(args),
|
||||||
Cmd::New(args) => new::exec(args),
|
|
||||||
Cmd::Tx(sub_cmd) => tx::exec(sub_cmd),
|
Cmd::Tx(sub_cmd) => tx::exec(sub_cmd),
|
||||||
Cmd::Uplc(sub_cmd) => uplc::exec(sub_cmd),
|
Cmd::Uplc(sub_cmd) => uplc::exec(sub_cmd),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue