Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions crates/iii-worker/src/cli/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
// This software is patent protected. We welcome discussions - reach out at support@motia.dev
// See LICENSE and PATENTS files for details.

use clap::{Parser, Subcommand};
use clap::{Args, Parser, Subcommand};

/// Default engine WebSocket port (must match engine's DEFAULT_PORT).
pub const DEFAULT_PORT: u16 = 49134;

/// Shared arguments for `add` and `reinstall` commands.
#[derive(Args, Debug)]
pub struct AddArgs {
/// Worker names or OCI image references (e.g., "pdfkit", "pdfkit@1.0.0", "ghcr.io/org/worker:tag")
#[arg(value_name = "WORKER[@VERSION]", required = true, num_args = 1..)]
pub worker_names: Vec<String>,

/// Reset config: also remove config.yaml entry before re-adding (requires --force on add)
#[arg(long)]
pub reset_config: bool,
}

#[derive(Parser, Debug)]
#[command(name = "iii-worker", version, about = "iii managed worker runtime")]
pub struct Cli {
Expand All @@ -20,9 +32,12 @@ pub struct Cli {
pub enum Commands {
/// Add one or more workers from the registry or by OCI image reference
Add {
/// Worker names or OCI image references (e.g., "pdfkit", "pdfkit@1.0.0", "ghcr.io/org/worker:tag")
#[arg(value_name = "WORKER[@VERSION]", required = true, num_args = 1..)]
worker_names: Vec<String>,
#[command(flatten)]
args: AddArgs,

/// Force re-download: delete existing artifacts before adding
#[arg(long, short = 'f')]
force: bool,
},

/// Remove one or more workers (stops and removes containers)
Expand All @@ -32,6 +47,23 @@ pub enum Commands {
worker_names: Vec<String>,
},

/// Re-download a worker (equivalent to `add --force`; pass `--reset-config` to also clear config.yaml)
Reinstall {
#[command(flatten)]
args: AddArgs,
},

/// Clear downloaded worker artifacts from ~/.iii/ (local-only, no engine connection needed)
Clear {
/// Worker name to clear (omit to clear all)
#[arg(value_name = "WORKER")]
worker_name: Option<String>,

/// Skip confirmation prompt
#[arg(long, short = 'y')]
yes: bool,
},

/// Start a previously stopped managed worker container
Start {
/// Worker name to start
Expand Down
Loading
Loading