Author:
Hash:
Timestamp:
+49 -62 +/-5 browse
Kevin Schoon [me@kevinschoon.com]
2b12ee7a97bfd935bf6e0d5330b4f45c920f327e
Sat, 28 Mar 2026 10:50:02 +0000 (2 weeks ago)
| 1 | diff --git a/Cargo.lock b/Cargo.lock |
| 2 | index f79f4c1..0d19863 100644 |
| 3 | --- a/Cargo.lock |
| 4 | +++ b/Cargo.lock |
| 5 | @@ -323,12 +323,11 @@ version = "0.2.1" |
| 6 | dependencies = [ |
| 7 | "async-trait", |
| 8 | "ayllu_api", |
| 9 | + "ayllu_cmd", |
| 10 | "ayllu_config", |
| 11 | "ayllu_database", |
| 12 | "ayllu_git", |
| 13 | "ayllu_logging", |
| 14 | - "clap", |
| 15 | - "clap_complete", |
| 16 | "petgraph", |
| 17 | "serde", |
| 18 | "serde_json", |
| 19 | @@ -571,15 +570,6 @@ dependencies = [ |
| 20 | ] |
| 21 | |
| 22 | [[package]] |
| 23 | - name = "clap_complete" |
| 24 | - version = "4.5.65" |
| 25 | - source = "registry+https://github.com/rust-lang/crates.io-index" |
| 26 | - checksum = "430b4dc2b5e3861848de79627b2bedc9f3342c7da5173a14eaa5d0f8dc18ae5d" |
| 27 | - dependencies = [ |
| 28 | - "clap", |
| 29 | - ] |
| 30 | - |
| 31 | - [[package]] |
| 32 | name = "clap_derive" |
| 33 | version = "4.5.55" |
| 34 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 35 | diff --git a/ayllu-build/Cargo.toml b/ayllu-build/Cargo.toml |
| 36 | index fd4787f..7bc3fc6 100644 |
| 37 | --- a/ayllu-build/Cargo.toml |
| 38 | +++ b/ayllu-build/Cargo.toml |
| 39 | @@ -13,10 +13,9 @@ ayllu_database = {path = "../crates/database"} |
| 40 | ayllu_logging = {path = "../crates/logging"} |
| 41 | # ayllu_rpc = {path = "../crates/rpc"} |
| 42 | ayllu_git = {path = "../crates/git"} |
| 43 | + ayllu_cmd = {path = "../crates/cmd"} |
| 44 | |
| 45 | async-trait = { workspace = true } |
| 46 | - clap = { workspace = true } |
| 47 | - clap_complete = { workspace = true } |
| 48 | tracing = { workspace = true } |
| 49 | serde = { workspace = true } |
| 50 | petgraph = { workspace = true } |
| 51 | diff --git a/ayllu-build/src/main.rs b/ayllu-build/src/main.rs |
| 52 | index 8b9ea89..0203ddc 100644 |
| 53 | --- a/ayllu-build/src/main.rs |
| 54 | +++ b/ayllu-build/src/main.rs |
| 55 | @@ -1,10 +1,8 @@ |
| 56 | - use std::io::stdout; |
| 57 | - use std::path::{Path, PathBuf}; |
| 58 | + use std::path::Path; |
| 59 | |
| 60 | - use clap::{Command, CommandFactory, Parser, Subcommand, arg}; |
| 61 | - use clap_complete::{Generator, Shell, generate}; |
| 62 | use tracing::Level; |
| 63 | |
| 64 | + use ayllu_cmd::build::{Command, Commands}; |
| 65 | use ayllu_database::Builder; |
| 66 | |
| 67 | use crate::evaluate::{Runtime, Source}; |
| 68 | @@ -16,56 +14,12 @@ mod models; |
| 69 | |
| 70 | const DEFAULT_BUILD_FILE: &str = ".ayllu-build.json"; |
| 71 | |
| 72 | - #[derive(Parser)] |
| 73 | - #[command(author, version, about, long_about = None)] |
| 74 | - #[command(name = "ayllu-build")] |
| 75 | - #[command(about = "Ayllu Build System")] |
| 76 | - struct Cli { |
| 77 | - /// Path to your configuration file |
| 78 | - #[arg(short, long, value_name = "FILE")] |
| 79 | - config: Option<PathBuf>, |
| 80 | - |
| 81 | - /// Sets the logging level |
| 82 | - #[arg(short, long, value_name = "LEVEL")] |
| 83 | - level: Option<Level>, |
| 84 | - |
| 85 | - #[command(subcommand)] |
| 86 | - command: Commands, |
| 87 | - } |
| 88 | - |
| 89 | - #[derive(Subcommand, Debug, PartialEq)] |
| 90 | - enum Commands { |
| 91 | - /// generate autocomplete commands for common shells |
| 92 | - Complete { |
| 93 | - #[arg(long)] |
| 94 | - shell: Shell, |
| 95 | - }, |
| 96 | - /// evaluate a local build script |
| 97 | - Evaluate { |
| 98 | - /// Path to your configuration file |
| 99 | - #[arg(value_name = "FILE")] |
| 100 | - alternate_path: Option<PathBuf>, |
| 101 | - /// "Tee" output from the executor to your local stdout/stderr |
| 102 | - #[arg(short, long, action)] |
| 103 | - tee_output: bool, |
| 104 | - }, |
| 105 | - } |
| 106 | - |
| 107 | - fn print_completions<G: Generator>(generator: G, cmd: &mut Command) { |
| 108 | - generate(generator, cmd, cmd.get_name().to_string(), &mut stdout()); |
| 109 | - } |
| 110 | - |
| 111 | #[tokio::main(flavor = "current_thread")] |
| 112 | async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 113 | - let cli = Cli::parse(); |
| 114 | + let cli = ayllu_cmd::parse::<Command>(); |
| 115 | let cfg = config::load(cli.config.as_deref())?; |
| 116 | ayllu_logging::init(Level::INFO); // FIXME |
| 117 | match cli.command { |
| 118 | - Commands::Complete { shell } => { |
| 119 | - let mut cmd = Cli::command(); |
| 120 | - print_completions(shell, &mut cmd); |
| 121 | - Ok(()) |
| 122 | - } |
| 123 | Commands::Evaluate { |
| 124 | alternate_path, |
| 125 | tee_output, |
| 126 | diff --git a/crates/cmd/src/build.rs b/crates/cmd/src/build.rs |
| 127 | new file mode 100644 |
| 128 | index 0000000..47135fa |
| 129 | --- /dev/null |
| 130 | +++ b/crates/cmd/src/build.rs |
| 131 | @@ -0,0 +1,43 @@ |
| 132 | + use std::path::PathBuf; |
| 133 | + |
| 134 | + use clap::{Parser, Subcommand}; |
| 135 | + use tracing::Level; |
| 136 | + |
| 137 | + const LONG_ABOUT_DESCRIPTION: &str = r#" |
| 138 | + |
| 139 | + ayllu-build provides a continuous integration server that works both locally |
| 140 | + and on a remote server. |
| 141 | + "#; |
| 142 | + |
| 143 | + #[derive(Parser, Debug)] |
| 144 | + #[clap( |
| 145 | + version, |
| 146 | + about, |
| 147 | + name = "ayllu-shell", |
| 148 | + long_about=LONG_ABOUT_DESCRIPTION, |
| 149 | + )] |
| 150 | + pub struct Command { |
| 151 | + /// Path to your configuration file |
| 152 | + #[arg(short, long, value_name = "FILE")] |
| 153 | + pub config: Option<PathBuf>, |
| 154 | + |
| 155 | + /// Sets the logging level |
| 156 | + #[arg(short, long, value_name = "LEVEL")] |
| 157 | + pub level: Option<Level>, |
| 158 | + |
| 159 | + #[command(subcommand)] |
| 160 | + pub command: Commands, |
| 161 | + } |
| 162 | + |
| 163 | + #[derive(Subcommand, Debug, PartialEq)] |
| 164 | + pub enum Commands { |
| 165 | + /// evaluate a local build script |
| 166 | + Evaluate { |
| 167 | + /// Path to your configuration file |
| 168 | + #[arg(value_name = "FILE")] |
| 169 | + alternate_path: Option<PathBuf>, |
| 170 | + /// "Tee" output from the executor to your local stdout/stderr |
| 171 | + #[arg(short, long, action)] |
| 172 | + tee_output: bool, |
| 173 | + }, |
| 174 | + } |
| 175 | diff --git a/crates/cmd/src/lib.rs b/crates/cmd/src/lib.rs |
| 176 | index 9ea472d..7194359 100644 |
| 177 | --- a/crates/cmd/src/lib.rs |
| 178 | +++ b/crates/cmd/src/lib.rs |
| 179 | @@ -1,4 +1,5 @@ |
| 180 | pub mod ayllu; |
| 181 | + pub mod build; |
| 182 | pub mod keys; |
| 183 | pub mod migrate; |
| 184 | pub mod quipu; |