From 4794bcb2ada7f68bf70f3299c7b625ba1210f65b Mon Sep 17 00:00:00 2001 From: Ian Wijma Date: Fri, 5 Apr 2024 21:08:54 +1100 Subject: [PATCH] Beginnings of the list command --- src/commands/list.rs | 15 +++++++++++++++ src/commands/mod.rs | 3 ++- src/commands/run.rs | 2 +- src/main.rs | 7 +++++-- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/commands/list.rs diff --git a/src/commands/list.rs b/src/commands/list.rs new file mode 100644 index 0000000..3433fc6 --- /dev/null +++ b/src/commands/list.rs @@ -0,0 +1,15 @@ +use clap::Args; + +#[derive(Args, Debug)] +pub struct Arguments { + #[arg(long, default_value = ".", help = "Which directory to use as entry, defaults to the current directory")] + entry: String, +} + +pub fn execute (arguments: &Arguments) -> Result<(), String> { + let Arguments { entry } = arguments; + + eprintln!("entry = {:?}", entry); + + Ok(()) +} \ No newline at end of file diff --git a/src/commands/mod.rs b/src/commands/mod.rs index a1f1444..bfb5fb2 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1 +1,2 @@ -pub mod run; \ No newline at end of file +pub mod run; +pub mod list; \ No newline at end of file diff --git a/src/commands/run.rs b/src/commands/run.rs index a5e3bd6..41c500e 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -19,7 +19,7 @@ pub struct Arguments { entry: String, } -pub fn run (arguments: &Arguments) -> Result<(), String> { +pub fn execute (arguments: &Arguments) -> Result<(), String> { let Arguments { entry, task_name } = arguments; // Start the timer diff --git a/src/main.rs b/src/main.rs index 1f6fabf..6a4e282 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,15 @@ use std::process::exit; use clap::{Parser, Subcommand}; use commands::run; +use commands::list; mod commands; mod utils; #[derive(Subcommand, Debug)] enum Command { - Run(run::Arguments) + Run(run::Arguments), + List(list::Arguments), } #[derive(Parser, Debug)] @@ -21,7 +23,8 @@ fn main() { let arguments = Arguments::parse(); let result = match &arguments.command { - Command::Run(arguments) => { run::run(arguments) } + Command::Run(arguments) => { run::execute(arguments) }, + Command::List(arguments) => { list::execute(arguments) }, }; match result {