From b60629489274a4be829056d30b8275b0a46094a3 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:29:29 +0000 Subject: [PATCH] wip --- src/cli/completion.rs | 1 + src/cli/{ => config}/add.rs | 0 src/cli/config/mod.rs | 26 ++++++++++++++++++++++++++ src/cli/{ => config}/remove.rs | 0 src/cli/mod.rs | 9 +++------ src/cli/supervisor/mod.rs | 1 + 6 files changed, 31 insertions(+), 6 deletions(-) rename src/cli/{ => config}/add.rs (100%) create mode 100644 src/cli/config/mod.rs rename src/cli/{ => config}/remove.rs (100%) diff --git a/src/cli/completion.rs b/src/cli/completion.rs index 92274b6..a53a8a2 100644 --- a/src/cli/completion.rs +++ b/src/cli/completion.rs @@ -2,6 +2,7 @@ use crate::Result; use duct::cmd; use miette::IntoDiagnostic; +/// Generates shell completion scripts #[derive(Debug, clap::Args)] #[clap()] pub struct Completion { diff --git a/src/cli/add.rs b/src/cli/config/add.rs similarity index 100% rename from src/cli/add.rs rename to src/cli/config/add.rs diff --git a/src/cli/config/mod.rs b/src/cli/config/mod.rs new file mode 100644 index 0000000..8272396 --- /dev/null +++ b/src/cli/config/mod.rs @@ -0,0 +1,26 @@ +use crate::Result; + +mod add; +mod remove; + +/// manage/edit pitchfork.toml files +#[derive(Debug, clap::Args)] +pub struct Config { + #[clap(subcommand)] + command: Commands, +} + +#[derive(Debug, clap::Subcommand)] +enum Commands { + Add(add::Add), + Remove(remove::Remove), +} + +impl Config { + pub async fn run(self) -> Result<()> { + match self.command { + Commands::Add(add) => add.run().await, + Commands::Remove(remove) => remove.run().await, + } + } +} diff --git a/src/cli/remove.rs b/src/cli/config/remove.rs similarity index 100% rename from src/cli/remove.rs rename to src/cli/config/remove.rs diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 27f6068..31a52b4 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -2,15 +2,14 @@ use crate::Result; use clap::Parser; mod activate; -mod add; mod cd; mod clean; mod completion; +mod config; mod disable; mod enable; mod list; mod logs; -mod remove; mod run; mod start; mod status; @@ -28,15 +27,14 @@ struct Cli { #[derive(Debug, clap::Subcommand)] enum Commands { Activate(activate::Activate), - Add(add::Add), Cd(cd::Cd), Clean(clean::Clean), + Config(config::Config), Completion(completion::Completion), Disable(disable::Disable), Enable(enable::Enable), List(list::List), Logs(logs::Logs), - Remove(remove::Remove), Run(run::Run), Start(start::Start), Status(status::Status), @@ -51,15 +49,14 @@ pub async fn run() -> Result<()> { let args = Cli::parse(); match args.command { Commands::Activate(activate) => activate.run().await, - Commands::Add(add) => add.run().await, Commands::Cd(cd) => cd.run().await, Commands::Clean(clean) => clean.run().await, + Commands::Config(config) => config.run().await, Commands::Completion(completion) => completion.run().await, Commands::Disable(disable) => disable.run().await, Commands::Enable(enable) => enable.run().await, Commands::List(list) => list.run().await, Commands::Logs(logs) => logs.run().await, - Commands::Remove(remove) => remove.run().await, Commands::Run(run) => run.run().await, Commands::Start(start) => start.run().await, Commands::Status(status) => status.run().await, diff --git a/src/cli/supervisor/mod.rs b/src/cli/supervisor/mod.rs index 756fba0..1198449 100644 --- a/src/cli/supervisor/mod.rs +++ b/src/cli/supervisor/mod.rs @@ -5,6 +5,7 @@ mod start; mod status; mod stop; +/// Start, stop, and check the status of the pitchfork supervisor daemon #[derive(Debug, clap::Args)] pub struct Supervisor { #[clap(subcommand)]