#!/usr/bin/env nu # Thin entry for job (orchestrator runtime) commands. # Loads only orchestration/workflows/management.nu + auth check helpers as needed. export-env { let lib_dirs_raw = ($env.NU_LIB_DIRS? | default "") let current_lib_dirs = if ($lib_dirs_raw | type) == "string" { if ($lib_dirs_raw | is-empty) { [] } else { ($lib_dirs_raw | split row ":") } } else { $lib_dirs_raw } let dynamic = ($env.PROVISIONING? | default "" | path join "core" "nulib") $env.NU_LIB_DIRS = ([ "/opt/provisioning/core/nulib" "/usr/local/provisioning/core/nulib" ] | append $current_lib_dirs | append (if ($dynamic | is-not-empty) { [$dynamic] } else { [] })) } use orchestration/workflows/management.nu * def main [ ...args: string --orchestrator: string = "" --status: string = "" --days: int = 7 --dry-run --debug (-x) ]: nothing -> nothing { if $debug { $env.PROVISIONING_DEBUG = true } let rest = if (($args | length) > 0) and (($args | first) in ["job", "j"]) { $args | skip 1 } else { $args } let sub = ($rest | get 0? | default "help") let arg1 = ($rest | get 1? | default "") match $sub { "list" | "ls" | "l" => { let limit_arg = if ($arg1 | is-not-empty) { let r = (do { $arg1 | into int } | complete) if $r.exit_code == 0 { ($r.stdout | str trim | into int) } else { null } } else { null } if $limit_arg != null { job list $limit_arg --orchestrator $orchestrator --status $status } else { job list --orchestrator $orchestrator --status $status } } "status" | "st" => { if ($arg1 | is-empty) { print "Error: job status requires a job id" return } job status $arg1 --orchestrator $orchestrator } "monitor" | "m" => { if ($arg1 | is-empty) { print "Error: job monitor requires a job id" return } job monitor $arg1 --orchestrator $orchestrator } "stats" => { job stats --orchestrator $orchestrator } "browse" | "b" => { let limit_arg = if ($arg1 | is-not-empty) { let r = (do { $arg1 | into int } | complete) if $r.exit_code == 0 { ($r.stdout | str trim | into int) } else { null } } else { null } if $limit_arg != null { job browse $limit_arg --orchestrator $orchestrator } else { job browse --orchestrator $orchestrator } } "orchestrator" | "o" => { job orchestrator --orchestrator $orchestrator } "cleanup" | "c" => { if $dry_run { job cleanup --days $days --orchestrator $orchestrator --dry-run } else { job cleanup --days $days --orchestrator $orchestrator } } "help" | "h" | "-h" | "--help" => { print "Orchestrator Job Management" print "===========================" print "" print "Jobs are RUNTIME executions tracked by the orchestrator daemon." print "Not to be confused with 'workflow' (WorkflowDef declarative recipes)." print "" print "Usage: prvng job [options]" print "" print "Subcommands:" print " list [limit] (alias: ls, l) — list recent jobs" print " status (alias: st) — show job status" print " monitor (alias: m) — follow job progress" print " stats — orchestrator stats" print " browse [limit] (alias: b) — interactive browser" print " orchestrator (alias: o) — orchestrator health" print " cleanup (alias: c) — clean old jobs [--days N] [--dry-run]" } _ => { print $"Unknown job subcommand: ($sub)" print "Run: prvng job help" } } }