Skip to content

Commit

Permalink
fix todo
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Nov 23, 2023
1 parent c21b654 commit ebb1971
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/bin/stellar-xdr/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use clap::Error;
use std::env;
use stellar_xdr::cli;

fn main() {
if let Err(e) = cli::run() {
if let Err(e) = cli::run(env::args_os()) {
Error::raw(clap::error::ErrorKind::ValueValidation, e).exit();
}
}
14 changes: 8 additions & 6 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod types;
mod version;

use clap::{Parser, Subcommand, ValueEnum};
use std::{error::Error, fmt::Debug};
use std::{error::Error, ffi::OsString, fmt::Debug};

#[derive(Parser, Debug, Clone)]
#[command(
Expand Down Expand Up @@ -54,15 +54,17 @@ enum Cmd {
Version,
}

/// Run the CLI.
///
/// TODO: How to pass in input to run from other CLI?
/// Run the CLI with the given args.
///
/// ## Errors
///
/// If the input cannot be parsed.
pub fn run() -> Result<(), Box<dyn Error>> {
let root = Root::try_parse()?;
pub fn run<I, T>(args: I) -> Result<(), Box<dyn Error>>
where
I: IntoIterator<Item = T>,
T: Into<OsString> + Clone,
{
let root = Root::try_parse_from(args)?;
match root.cmd {
Cmd::Types(c) => c.run(&root.channel)?,
Cmd::Guess(c) => c.run(&root.channel)?,
Expand Down

0 comments on commit ebb1971

Please sign in to comment.