Move build/dev/generate/publish under plugin command

This commit is contained in:
Gregory Schier
2026-02-22 08:39:38 -08:00
parent 51959bf3f3
commit 5acd8f661f
3 changed files with 34 additions and 16 deletions

View File

@@ -26,17 +26,8 @@ pub enum Commands {
/// Authentication commands
Auth(AuthArgs),
/// Transpile code into a runnable plugin bundle
Build(PluginPathArg),
/// Build plugin bundle continuously when the filesystem changes
Dev(PluginPathArg),
/// Generate a "Hello World" Yaak plugin
Generate(GenerateArgs),
/// Publish a Yaak plugin version to the plugin registry
Publish(PluginPathArg),
/// Plugin development and publishing commands
Plugin(PluginArgs),
/// Send a request, folder, or workspace by ID
Send(SendArgs),
@@ -339,6 +330,27 @@ pub enum AuthCommands {
Whoami,
}
#[derive(Args)]
pub struct PluginArgs {
#[command(subcommand)]
pub command: PluginCommands,
}
#[derive(Subcommand)]
pub enum PluginCommands {
/// Transpile code into a runnable plugin bundle
Build(PluginPathArg),
/// Build plugin bundle continuously when the filesystem changes
Dev(PluginPathArg),
/// Generate a "Hello World" Yaak plugin
Generate(GenerateArgs),
/// Publish a Yaak plugin version to the plugin registry
Publish(PluginPathArg),
}
#[derive(Args, Clone)]
pub struct PluginPathArg {
/// Path to plugin directory (defaults to current working directory)

View File

@@ -1,4 +1,4 @@
use crate::cli::{GenerateArgs, PluginPathArg};
use crate::cli::{GenerateArgs, PluginArgs, PluginCommands, PluginPathArg};
use crate::ui;
use keyring::Entry;
use rand::Rng;
@@ -57,6 +57,15 @@ pub async fn run_build(args: PluginPathArg) -> i32 {
}
}
pub async fn run(args: PluginArgs) -> i32 {
match args.command {
PluginCommands::Build(args) => run_build(args).await,
PluginCommands::Dev(args) => run_dev(args).await,
PluginCommands::Generate(args) => run_generate(args).await,
PluginCommands::Publish(args) => run_publish(args).await,
}
}
pub async fn run_dev(args: PluginPathArg) -> i32 {
match dev(args).await {
Ok(()) => 0,

View File

@@ -48,10 +48,7 @@ async fn main() {
let exit_code = match command {
Commands::Auth(args) => commands::auth::run(args).await,
Commands::Build(args) => commands::plugin::run_build(args).await,
Commands::Dev(args) => commands::plugin::run_dev(args).await,
Commands::Generate(args) => commands::plugin::run_generate(args).await,
Commands::Publish(args) => commands::plugin::run_publish(args).await,
Commands::Plugin(args) => commands::plugin::run(args).await,
Commands::Send(args) => {
commands::send::run(
context.as_ref().expect("context initialized for send"),