Skip to content

Commit

Permalink
fix: generic help message cli (#91)
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
berendsliedrecht authored Mar 9, 2022
1 parent 6b95667 commit c8c8523
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::modules::{
};

#[derive(Parser)]
#[clap(author, version, about)]
#[clap(name = "aries-cli", author, version, about = HelpStrings::Cli)]
#[clap(arg_required_else_help = true)]
pub struct Cli {
#[clap(long, short, help = HelpStrings::Endpoint)]
Expand Down
67 changes: 46 additions & 21 deletions cli/src/help_strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,58 @@ use std::convert::From;
/// Help documentation for CLI commands.
pub enum HelpStrings {
Endpoint,
ApiKey,
Copy,
Quiet,
Verbose,
Config,
Environment,
Cli,
Endpoint,
ApiKey,
Copy,
Quiet,
Verbose,
Config,
Environment,
}

impl From<HelpStrings> for Option<&str> {
fn from(help_string: HelpStrings) -> Option<&'static str> {
Some(help_string.as_str())
}
fn from(help_string: HelpStrings) -> Option<&'static str> {
Some(help_string.as_str())
}
}

impl HelpStrings {
fn as_str(&self) -> &'static str {
match self {
HelpStrings::Endpoint => "The Aries agent endpoint requests are sent to",
HelpStrings::ApiKey => "This API key will be passed to the agent.",
HelpStrings::Copy => "Copy output to your clipboard.",
HelpStrings::Quiet => "Suppresses most output.",
HelpStrings::Verbose => "Print debug logs.",
HelpStrings::Config => "Path to your configuration file.",
HelpStrings::Environment => "Specify your current environment.",
// TODO: Add docs for all subcommands, e.g., ConnectionsAll.
fn as_str(&self) -> &'static str {
match self {
HelpStrings::Cli => HELP_STRING_CLI,
HelpStrings::Endpoint => "The Aries agent endpoint requests are sent to",
HelpStrings::ApiKey => "This API key will be passed to the agent.",
HelpStrings::Copy => "Copy output to your clipboard.",
HelpStrings::Quiet => "Suppresses most output.",
HelpStrings::Verbose => "Print debug logs.",
HelpStrings::Config => "Path to your configuration file.",
HelpStrings::Environment => "Specify your current environment.",
// TODO: Add docs for all subcommands, e.g., ConnectionsAll.
}
}
}
}

const HELP_STRING_CLI: &str = "
--- Aries cli ---
To begin working with the aries-cli, run the following command:
$ aries-cli configuration initialize
This command will initialize the configuration file and makes sure
that you do not have to pass the --endpoint argument with every call.
Some example commands are the following:
$ aries-cli connections
- fetches all the connections (jq compatible)
$ aries-cli connections invite -qr
- create an invitation (as a qr code)
$ aries-cli features
- Fetches all the features of the cloudagent
$ aries-cli schema create --name FOO -a BAR -a BAZ
- Create a new schema with the name as 'FOO' and the attributes as 'BAR' and 'BAZ'
-----------------
";

0 comments on commit c8c8523

Please sign in to comment.