Skip to content

Commit

Permalink
fix(CLI): Consistent ordering and color for help
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Apr 5, 2021
1 parent c13824b commit 71f4cd3
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 16 deletions.
21 changes: 15 additions & 6 deletions rust/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ pub mod cli {
#[derive(Debug, StructOpt)]
#[structopt(
about = "Manage configuration options",
setting = structopt::clap::AppSettings::ColoredHelp
setting = structopt::clap::AppSettings::ColoredHelp,
setting = structopt::clap::AppSettings::VersionlessSubcommands
)]
pub struct Args {
#[structopt(subcommand)]
Expand All @@ -210,12 +211,18 @@ pub mod cli {
Set(Set),
Reset(Reset),

#[structopt(about = "Get the directories used for config, cache etc")]
#[structopt(
about = "Get the directories used for config, cache etc",
setting = structopt::clap::AppSettings::ColoredHelp
)]
Dirs,
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Get configuration properties")]
#[structopt(
about = "Get configuration properties",
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Get {
/// A pointer to a config property e.g. `upgrade.auto`
pub pointer: Option<String>,
Expand All @@ -224,8 +231,7 @@ pub mod cli {
#[derive(Debug, StructOpt)]
#[structopt(
about = "Set configuration properties",
setting = structopt::clap::AppSettings::TrailingVarArg,
setting = structopt::clap::AppSettings::AllowLeadingHyphen
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Set {
/// A pointer to a config property e.g. `upgrade.auto`
Expand All @@ -236,7 +242,10 @@ pub mod cli {
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Reset configuration properties to their defaults")]
#[structopt(
about = "Reset configuration properties to their defaults",
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Reset {
/// The config property to reset. Use 'all' to reset the entire config.
pub property: String,
Expand Down
6 changes: 6 additions & 0 deletions rust/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,25 @@ pub mod cli {
#[derive(Debug, StructOpt)]
#[structopt(
about = "Convert a document from one format to another",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Args {
/// The input file or URL to convert from
input: String,

/// The output file to convert to
output: String,

/// The format of the input (defaults to being inferred from the file extension or content type)
#[structopt(short, long)]
from: Option<String>,

/// The format of the output (defaults to being inferred from the file extension)
#[structopt(short, long)]
to: Option<String>,

/// Watch for changes in the input and redo conversion automatically (if input is local file)
#[structopt(short, long)]
watch: bool,
}
Expand Down
56 changes: 46 additions & 10 deletions rust/src/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,8 @@ pub mod cli {
#[derive(Debug, StructOpt)]
#[structopt(
about = "Manage plugins",
setting = structopt::clap::AppSettings::ColoredHelp
setting = structopt::clap::AppSettings::ColoredHelp,
setting = structopt::clap::AppSettings::VersionlessSubcommands
)]
pub struct Args {
#[structopt(subcommand)]
Expand All @@ -774,7 +775,10 @@ pub mod cli {
setting = structopt::clap::AppSettings::DeriveDisplayOrder
)]
pub enum Action {
#[structopt(about = "List installed plugins")]
#[structopt(
about = "List installed plugins",
setting = structopt::clap::AppSettings::ColoredHelp
)]
List,
Show(Show),
Install(Install),
Expand All @@ -787,7 +791,11 @@ pub mod cli {
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Show the details of an installed plugin")]
#[structopt(
about = "Show the details of an installed plugin",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Show {
/// The name of the plugin to show
#[structopt()]
Expand All @@ -799,7 +807,11 @@ pub mod cli {
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Install one or more plugins")]
#[structopt(
about = "Install one or more plugins",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Install {
/// Attempt to add plugins as Docker image
#[structopt(short, long)]
Expand All @@ -819,15 +831,23 @@ pub mod cli {
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Link to a local plugins")]
#[structopt(
about = "Link to a local plugins",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Link {
/// The path of a plugin directory
#[structopt()]
pub path: String,
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Upgrade one of more plugins")]
#[structopt(
about = "Upgrade one of more plugins",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Upgrade {
/// The names or aliases of plugins to upgrade
/// (omit to upgrade all plugins)
Expand All @@ -836,23 +856,35 @@ pub mod cli {
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Uninstall one or more plugins")]
#[structopt(
about = "Uninstall one or more plugins",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Uninstall {
/// The names or aliases of plugins to uninstall
#[structopt(required = true, multiple = true)]
pub plugins: Vec<String>,
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Unlink a local plugins")]
#[structopt(
about = "Unlink a local plugins",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Unlink {
/// The name of the plugin to unlink
#[structopt()]
pub plugin: String,
}

#[derive(Debug, StructOpt)]
#[structopt(about = "List methods and the plugins that implement them")]
#[structopt(
about = "List methods and the plugins that implement them",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Methods {
/// The name of the method to display
#[structopt()]
Expand All @@ -864,7 +896,11 @@ pub mod cli {
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Delegate a method call to any, or a particular, plugin")]
#[structopt(
about = "Delegate a method call to any, or a particular, plugin",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Delegate {
/// The method to call
#[structopt()]
Expand Down
1 change: 1 addition & 0 deletions rust/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ pub mod cli {
#[derive(Debug, StructOpt)]
#[structopt(
about = "Serve on HTTP, WebSockets, or Standard I/O",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Args {
Expand Down
1 change: 1 addition & 0 deletions rust/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ pub mod cli {
#[derive(Debug, StructOpt)]
#[structopt(
about = "Upgrade to the latest (or other) version",
setting = structopt::clap::AppSettings::DeriveDisplayOrder,
setting = structopt::clap::AppSettings::ColoredHelp
)]
pub struct Args {
Expand Down

0 comments on commit 71f4cd3

Please sign in to comment.