Skip to content

Commit

Permalink
add command help
Browse files Browse the repository at this point in the history
  • Loading branch information
ryqdev committed Jun 1, 2024
1 parent a4515c8 commit 8d7abbb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
use crate::cmds::backtest::BackTestCommand;
use crate::cmds::Command;
use crate::cmds::live::LiveTradingCommand;
use crate::cmds::paper::PaperTradingCommand;
use crate::cmds::{
Command,
backtest::BackTestCommand,
live::LiveTradingCommand,
paper::PaperTradingCommand
};
use anyhow::Result;


pub async fn match_cmds() -> anyhow::Result<()> {
pub async fn match_cmds() -> Result<()> {
match clap::Command::new("golden")
.subcommands(vec![
BackTestCommand::usage().display_order(1),
PaperTradingCommand::usage().display_order(2),
LiveTradingCommand::usage().display_order(3)
])
.arg_required_else_help(true)
.get_matches()
.subcommand()
{
Some(("backtest", sub_m)) => Ok(BackTestCommand::handler(sub_m).await?),
Some(("paper-trading", sub_m)) => Ok(PaperTradingCommand::handler(sub_m).await?),
Some(("live-trading", sub_m)) => Ok(LiveTradingCommand::handler(sub_m).await?),
_ => Err(anyhow::Error::msg("Miss arguments. Please open Makefile to get instructions")),
_ => Err(anyhow::Error::msg("Match commands fails")),
}
}
2 changes: 1 addition & 1 deletion src/err.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#[derive(Debug)]
pub enum Error {
MatchError,
CSVError,
}

0 comments on commit 8d7abbb

Please sign in to comment.