Skip to content

Commit

Permalink
Minor XDGB edge cases (#1425)
Browse files Browse the repository at this point in the history
This fixes 3 minor issues:

1) when the user does not specify a subcommand XDBG exits with code 0. This can be a bit confusing. Print help instead and exit with an error.
- I am open to other options. Printing to stderr and std::process:exit(1) are also pretty good choices.



2) Generate could not print help

```
$ cargo run --package xdbg -- generate -h
    Finished `dev` profile [unoptimized] target(s) in 0.19s
     Running `target/debug/xdbg generate -h`
The application panicked (crashed).
Message:  Command generate: Short option names must be unique for each argument, but '-i' is in use by both 'invite' and 'interval'
Location: /Users/martinkysel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.23/src/builder/debug_asserts.rs:112
```

Now it can

3) Typo in `loclalhosltls`
  • Loading branch information
mkysel authored Dec 16, 2024
1 parent a090c87 commit 567751f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions xmtp_debug/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mod store;
/// Types shared between App Functions
mod types;

use clap::CommandFactory;
use color_eyre::eyre::{self, Result};
use directories::ProjectDirs;
use std::{fs, path::PathBuf, sync::Arc};
Expand Down Expand Up @@ -95,6 +96,11 @@ impl App {
} = opts;
debug!(fdlimit = get_fdlimit());

if cmd.is_none() && !clear {
AppOpts::command().print_help()?;
eyre::bail!("No subcommand was specified");
}

if let Some(cmd) = cmd {
match cmd {
Generate(g) => generate::Generate::new(g, backend, db).run().await,
Expand Down
2 changes: 1 addition & 1 deletion xmtp_debug/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct Generate {
#[arg(long, short)]
pub amount: usize,
/// Specify amount of random identities to invite to group
#[arg(long, short)]
#[arg(long)]
pub invite: Option<usize>,
#[command(flatten)]
pub message_opts: MessageGenerateOpts,
Expand Down
2 changes: 1 addition & 1 deletion xmtp_debug/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub static XMTP_PRODUCTION_D14N: LazyLock<Url> = LazyLock::new(|| Url::parse("")
pub static XMTP_DEV_D14N: LazyLock<Url> =
LazyLock::new(|| Url::parse("https://grpc.testnet.xmtp.network:443").unwrap());
pub static XMTP_LOCAL_D14N: LazyLock<Url> =
LazyLock::new(|| Url::parse("http://localhots:5050").unwrap());
LazyLock::new(|| Url::parse("http://localhost:5050").unwrap());

pub static XMTP_PRODUCTION_PAYER: LazyLock<Url> = LazyLock::new(|| Url::parse("").unwrap());
pub static XMTP_DEV_PAYER: LazyLock<Url> =
Expand Down

0 comments on commit 567751f

Please sign in to comment.