Skip to content

Commit 5cf31a7

Browse files
chore(deps): review dependencies and optimize commands
1 parent 58cd434 commit 5cf31a7

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ serde_json = "1"
2020
tokio = { version = "1", features = ["full"] }
2121
anyhow = "1"
2222
base64 = "0.22"
23+
billy-ray = { path = "billy-ray" }
2324

2425
[[bin]]
2526
name = "openapi"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ With the Openapi CLI, you can easily interact with a variety of services in the
3636
- Query company data, risk reports, automotive records, and more
3737

3838
For a complete list of all available services, check out the [Openapi® Marketplace](https://console.openapi.com/).
39+
There is also a small terminal easter egg available through `openapi --who`.
3940

4041
## Installation
4142

src/cli.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ pub struct Cli {
1414
#[arg(short = 'S', long, global = true)]
1515
pub sandbox: bool,
1616

17+
/// Discover who you are
18+
#[arg(long, global = true)]
19+
pub who: bool,
20+
1721
#[command(subcommand)]
18-
pub command: Commands,
22+
pub command: Option<Commands>,
1923
}
2024

2125
#[derive(Debug, Subcommand)]

src/main.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod config;
55
mod scopes;
66

77
use anyhow::Result;
8-
use clap::Parser;
8+
use clap::{CommandFactory, Parser};
99

1010
use cli::{Cli, Commands};
1111
use client::{ApiClient, OAuthClient};
@@ -15,12 +15,23 @@ use config::{Config, OAuthConfig};
1515
async fn main() -> Result<()> {
1616
let cli = Cli::parse();
1717

18-
if let Commands::Info = &cli.command {
18+
if cli.who {
19+
billy_ray::run()?;
20+
return Ok(());
21+
}
22+
23+
let Some(command) = &cli.command else {
24+
Cli::command().print_help()?;
25+
println!();
26+
return Ok(());
27+
};
28+
29+
if let Commands::Info = command {
1930
return commands::info::execute().await;
2031
}
2132

2233
// Token management uses Basic auth (OPENAPI_USERNAME + OPENAPI_KEY)
23-
if let Commands::Token { command } = &cli.command {
34+
if let Commands::Token { command } = command {
2435
let oauth_config = OAuthConfig::load(cli.sandbox)?;
2536
let oauth_client = OAuthClient::new(oauth_config)?;
2637
return commands::token::execute(command, &oauth_client).await;
@@ -30,7 +41,7 @@ async fn main() -> Result<()> {
3041
let config = Config::load(cli.sandbox)?;
3142
let client = ApiClient::new(config)?;
3243

33-
match &cli.command {
44+
match command {
3445
Commands::Esignature { command } => commands::esignature::execute(command, &client).await,
3546
Commands::Ai { command } => commands::ai::execute(command, &client).await,
3647
Commands::Sms { command } => commands::sms::execute(command, &client).await,

0 commit comments

Comments
 (0)