Commit 98481626 authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

wip: Intial scaffolding for create subcommand

parent d2a1e61c
Loading
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -326,6 +326,17 @@ pub enum Commands {
        #[command(flatten)]
        verbose: Verbosity,
    },
    /// Create research resources like GitLab runners, MCP servers, etc.
    ///
    ///     $> acorn create runner --config ./acorn.json
    ///
    ///     $> acorn create runner --group 12345
    ///
    #[clap(verbatim_doc_comment, next_help_heading = "FLAGS")]
    Create {
        #[command(subcommand)]
        command: Option<CreateCommands>,
    },
    /// Diagnose and correct system requirements for using acorn
    ///
    ///     Print system diagnostics and identify issues
@@ -605,6 +616,32 @@ pub enum Commands {
}
#[derive(Debug, Subcommand)]
#[command(long_about = None)]
pub enum CreateCommands {
    /// Model context provider (MCP) server
    Mcp {},
    /// GitLab runner
    Runner {
        /// Path to configuration file for creating the resource
        #[arg(short, long, default_value = "./", value_name = "PATH", value_hint = ValueHint::FilePath, help_heading = "OPTIONS")]
        config: Option<PathBuf>,
        /// Runner description (alternative to providing a configuration file)
        #[arg(short, long, value_name = "DESCRIPTION", help_heading = "OPTIONS")]
        description: Option<String>,
        /// GitLab group ID to create a runner for (alternative to providing a configuration file)
        #[arg(short, long, conflicts_with = "project", value_name = "ID", help_heading = "OPTIONS")]
        group: Option<u64>,
        /// GitLab project ID to create a runner for (alternative to providing a configuration file)
        #[arg(short, long, conflicts_with = "group", value_name = "ID", help_heading = "OPTIONS")]
        project: Option<u64>,
        /// Tags to register the runner with (alternative to providing a configuration file)
        #[arg(short, long, value_name = "LIST", value_delimiter = ',', help_heading = "OPTIONS")]
        tags: Vec<String>,
        #[command(flatten)]
        verbose: Verbosity,
    },
}
#[derive(Debug, Subcommand)]
#[command(long_about = None)]
pub enum SchemaCommands {
    /// Print research activity data (RAD) JSON schema to stdout
    Rad {},
+15 −0
Original line number Diff line number Diff line
use acorn::prelude::PathBuf;
use clap_verbosity_flag::Verbosity;
use color_eyre::eyre::{Report, Result};

pub async fn run(
    config: &Option<PathBuf>,
    _description: &Option<String>,
    _group: &Option<u64>,
    _project: &Option<u64>,
    _tags: &Vec<String>,
    _verbose: &Verbosity,
) -> Result<(), Report> {
    dbg!(&config);
    Ok(())
}
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ use acorn::util::Label;
use std::process::exit;

pub mod check;
pub mod create;
pub mod doctor;
pub mod download;
pub mod export;
+16 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ mod commands;
mod io;
mod template;

use cli::{Arguments, Commands, SchemaCommands};
use cli::{Arguments, Commands, CreateCommands, SchemaCommands};

/// Return type for main function
pub type Void = eyre::Result<(), eyre::Report>;
@@ -249,6 +249,21 @@ async fn main() -> Void {
            )
            .await
        }
        | Some(Commands::Create { command, .. }) => match command {
            | Some(CreateCommands::Mcp {}) => unimplemented!("MCP server creation is not yet implemented"),
            | Some(CreateCommands::Runner {
                config,
                description,
                group,
                project,
                tags,
                verbose,
            }) => commands::create::run(config, description, group, project, tags, verbose).await,
            | None => {
                eprintln!("=> {} No subcommand provided for 'create'", Label::fail());
                exit(exitcode::USAGE);
            }
        },
        | Some(Commands::Doctor { fix, interactive, check, .. }) => commands::doctor::run(fix, interactive, check, offline).await,
        | Some(Commands::Download {
            config,