Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(serverAddr, username string) error

func CreateUser

func CreateUser(client pb.TaskQueueClient, user *pb.CreateUserRequest) error

func DeleteUser

func DeleteUser(client pb.TaskQueueClient, userId int32) error

func ListUsers

func ListUsers(client pb.TaskQueueClient) error

func Run

func Run(c CLI) error

func UpdateUser

func UpdateUser(client pb.TaskQueueClient, user *pb.User) error

Types

type Attr

type Attr struct {
	// Config commands
	Config *struct {
		ImportRclone *struct {
			Path string `arg:"positional" default:"~/.config/rclone/rclone.conf" help:"Path to existing rclone.conf to import"`
		} `arg:"subcommand:import-rclone" help:"Import an existing rclone.conf and print YAML fragment"`
	} `arg:"subcommand:config" help:"Configuration tools"`

	Server  string `arg:"-s,--server,env:SCITQ_SERVER" default:"localhost:50051" help:"gRPC server address"`
	TimeOut int    `arg:"-t,--timeout" default:"300" help:"Timeout for server interaction (in seconds)"`
	Token   string `arg:"-T,--token" default:"" help:"authentication token (used for tests)"`
	JSON    bool   `arg:"--json" help:"Output in JSON format (for scripting and AI agents)"`

	// Task Commands (Sub-Subcommands)
	Task *struct {
		Create *struct {
			Name         *string  `arg:"--name" help:"Optional name of the task"`
			Container    string   `arg:"--container,required" help:"Container to run"`
			Command      string   `arg:"--command,required" help:"Command to execute"`
			Shell        *string  `arg:"--shell" help:"Shell to use"`
			Input        []string `arg:"--input,separate" help:"Input values for the task (can be repeated)"`
			Resource     []string `arg:"--resource,separate" help:"Input values for the task (can be repeated)"`
			Output       string   `arg:"--output,separate" help:"Output folder where results are copied for the task"`
			StepId       *int32   `arg:"--step-id" help:"Step ID if task is affected to a step"`
			Dependencies []int32  `arg:"--dependency,separate" help:"IDs of tasks that this task depends on (can be repeated)"`
		} `arg:"subcommand:create" help:"Create a new task"`

		List *struct {
			Status     string `arg:"--status" help:"Filter tasks by status"`
			ShowHidden bool   `arg:"--show-hidden" help:"Include tasks marked as hidden (e.g., previous failed attempts)"`
			WorkerId   int32  `arg:"--worker-id" help:"Filter tasks by worker ID"`
			WorkflowId int32  `arg:"--workflow-id" help:"Filter tasks by workflow ID"`
			StepId     int32  `arg:"--step-id" help:"Filter tasks by step ID"`
			Command    string `arg:"--command" help:"Filter tasks by command substring"`
			Limit      int32  `arg:"--limit" default:"20" help:"Limit the number of tasks returned"`
			Offset     int32  `arg:"--offset" help:"Offset for pagination of tasks"`
		} `arg:"subcommand:list" help:"List all tasks"`

		Stdout *struct {
			ID int32 `arg:"--id,required" help:"Task ID"`
		} `arg:"subcommand:stdout" help:"Stream task stdout"`

		Stderr *struct {
			ID int32 `arg:"--id,required" help:"Task ID"`
		} `arg:"subcommand:stderr" help:"Stream task stderr"`

		Logs *struct {
			ID int32 `arg:"--id,required" help:"Task ID"`
		} `arg:"subcommand:logs" help:"Stream task stdout and stderr (colored)"`

		Retry *struct {
			ID    int32  `arg:"--id,required" help:"Task ID to retry"`
			Retry *int32 `arg:"--retry" help:"Number of retries left (optional)"`
		} `arg:"subcommand:retry" help:"Retry a failed task"`

		Edit *struct {
			ID      int32  `arg:"--id,required" help:"Task ID to edit and retry"`
			Command string `arg:"--command,required" help:"New command for the task"`
		} `arg:"subcommand:edit" help:"Edit a task's command and retry it"`
	} `arg:"subcommand:task" help:"Manage tasks"`

	// Worker Commands (Sub-Subcommands)
	Worker *struct {
		List *struct {
			Long bool `arg:"-l,--long" help:"Show extended worker details"`
		} `arg:"subcommand:list" help:"List all workers"`
		Deploy *struct {
			Flavor      string `arg:"--flavor,required" help:"Worker flavor"`
			Provider    string `arg:"--provider,required" help:"Worker provider in the form providerName.configName like azure.primary"`
			Region      string `arg:"--region" help:"Worker region, default to provider default region"`
			Count       int    `arg:"--count" help:"How many worker to create" default:"1"`
			StepId      int32  `arg:"--step" help:"Worker step ID if worker is affected to a task"`
			Concurrency int    `arg:"--concurrency" default:"1" help:"Worker initial concurrency"`
			Prefetch    int    `arg:"--prefetch" default:"0" help:"Worker initial prefetch"`
		} `arg:"subcommand:deploy" help:"Create and deploy a new worker instance"`
		Delete *struct {
			WorkerId int32 `arg:"--worker-id,required" help:"The ID of the worker to be deleted"`
		} `arg:"subcommand:delete" help:"Delete a worker instance"`
		Update *struct {
			WorkerId        int32   `arg:"--worker-id,required" help:"The ID of the worker to update"`
			StepId          *int32  `arg:"--step-id" help:"Step ID to assign the worker to"`
			WorkflowName    *string `arg:"--workflow-name" help:"Workflow name to resolve step (lowest step_id if --step-name omitted)"`
			StepName        *string `arg:"--step-name" help:"Step name to resolve step (requires --workflow-name)"`
			Concurrency     *int32  `arg:"--concurrency" help:"Update worker concurrency"`
			Prefetch        *int32  `arg:"--prefetch" help:"Update worker prefetch"`
			Permanent       bool    `arg:"--permanent" help:"Set worker as permanent"`
			NoPermanent     bool    `arg:"--no-permanent" help:"Unset permanent status"`
			RecyclableScope *string `arg:"--recyclable-scope" help:"Update recyclable scope"`
		} `arg:"subcommand:update" help:"Update worker settings"`
		Stats *struct {
			WorkerIds []int32 `arg:"--worker-id,separate,required" help:"Worker IDs to get stats for"`
		} `arg:"subcommand:stats" help:"Fetch current stats for workers"`
	} `arg:"subcommand:worker" help:"Manage workers"`

	// Flavor commands
	Flavor *struct {
		List *struct {
			Limit  int    `arg:"--limit" help:"Limit the number of answers" default:"10"`
			Filter string `arg:"--filter" help:"Filter flavor by a filter string like 'cpu>=12:mem>=30'"`
		} `arg:"subcommand:list" help:"List flavors"`
	} `arg:"subcommand:flavor" help:"Find flavors"`

	// User commands
	User *struct {
		List   *struct{} `arg:"subcommand:list" help:"List all users"`
		Update *struct {
			UserId   int32   `arg:"--id,required" help:"User ID to update"`
			Username *string `arg:"--username" help:"New username"`
			Email    *string `arg:"--email" help:"New email"`
			Admin    bool    `arg:"--admin" help:"Set admin status"`
			NoAdmin  bool    `arg:"--no-admin" help:"Remove admin rights"`
		} `arg:"subcommand:update" help:"Update a user"`
		Create *struct {
			Username string `arg:"--username,required" help:"New username"`
			Email    string `arg:"--email,required" help:"New email"`
			Password string `arg:"--password,required" help:"New password"`
			Admin    bool   `arg:"--admin" help:"Set admin status"`
		} `arg:"subcommand:create" help:"Create a new user"`
		Delete *struct {
			UserId int32 `arg:"--id,required" help:"User ID to delete"`
		} `arg:"subcommand:delete" help:"Delete a user"`
		ChangePassword *struct {
			Username string `arg:"--username,required" help:"Username for which password will be changed"`
		} `arg:"subcommand:change-password" help:"Change your password"`
	} `arg:"subcommand:user" help:"User management"`

	Recruiter *struct {
		List *struct {
			StepId int32 `arg:"--step-id" help:"Step ID to filter"`
		} `arg:"subcommand:list" help:"List all recruiters"`
		Create *struct {
			StepId          int32    `arg:"--step-id,required" help:"Step ID"`
			Rank            int32    `arg:"--rank" default:"1" help:"Recruiter rank"`
			Protofilter     string   `arg:"--filter,required" help:"A filter like 'cpu>=12:mem>=30' or 'flavor~Standard_D2s_%:region is default'"`
			Concurrency     *int32   `arg:"--concurrency" help:"Worker initial concurrency"`
			Prefetch        *int32   `arg:"--prefetch" help:"Worker initial prefetch"`
			PrefetchPercent *int32   `arg:"--prefetch-percent" help:"Worker initial prefetc (expressed as a %% of concurrency)"`
			CpuPerTask      *int32   `arg:"--cpu-per-task" help:"Adaptative concurrency: CPU required for 1 task"`
			MemoryPerTask   *float32 `arg:"--memory-per-task" help:"Adaptative concurrency: Memory (Gb) required for 1 task"`
			DiskPerTask     *float32 `arg:"--disk-per-task" help:"Adaptative concurrency: Disk space (Gb) required for 1 task"`
			ConcurrencyMax  *int32   `arg:"--concurrency" help:"Adaptative concurrency: Maximum concurrency per worker"`
			ConcurrencyMin  *int32   `arg:"--concurrency" help:"Adaptative concurrency: Minimal concurrency per worker"`
			MaxWorkers      *int32   `arg:"--max-workers" help:"Maximum number of workers"`
			Rounds          int      `arg:"--rounds" help:"Number of rounds"`
			Timeout         int      `arg:"--timeout" default:"10" help:"Timeout in seconds"`
		} `arg:"subcommand:create" help:"Create a new recruiter"`
		Delete *struct {
			StepId int32 `arg:"--step-id,required" help:"Step ID to delete"`
			Rank   int   `arg:"--rank,required" help:"Recruiter rank to delete"`
		} `arg:"subcommand:delete" help:"Delete a recruiter"`
	} `arg:"subcommand:recruiter" help:"Recruiter management"`

	// Workflow commands
	Workflow *struct {
		List *struct {
			NameLike string `arg:"--name-like" help:"Filter workflows by name"`
		} `arg:"subcommand:list" help:"List workflows"`
		Create *struct {
			Name           string `arg:"--name,required" help:"Workflow name"`
			RunStrategy    string `` /* 283-byte string literal not displayed */
			MaximumWorkers *int32 `arg:"--maximum-workers" help:"Maximum number of workers"`
			Status         string `arg:"--status" help:"Initial workflow status (P/R/Z/D/F/S). Default is P."`
		} `arg:"subcommand:create" help:"Create a new workflow"`
		Update *struct {
			WorkflowId int32  `arg:"--id,required" help:"Workflow ID to update"`
			Status     string `arg:"--status,required" help:"New workflow status (P/R/Z/D/F/S)"`
		} `arg:"subcommand:update" help:"Update workflow status"`
		Delete *struct {
			WorkflowId int32 `arg:"--id,required" help:"Workflow ID to delete"`
		} `arg:"subcommand:delete" help:"Delete a workflow"`
	} `arg:"subcommand:workflow" help:"Manage workflows"`

	// Step commands
	Step *struct {
		List *struct {
			WorkflowId int32 `arg:"--workflow-id,required" help:"Workflow ID to list steps for"`
		} `arg:"subcommand:list" help:"List steps for a workflow"`
		Create *struct {
			WorkflowId   int32  `arg:"--workflow-id" help:"Workflow ID"`
			WorkflowName string `arg:"--workflow-name" help:"Workflow name (alternative to ID)"`
			Name         string `arg:"--name,required" help:"Step name"`
		} `arg:"subcommand:create" help:"Create a step"`
		Delete *struct {
			StepId int32 `arg:"--id,required" help:"Step ID to delete"`
		} `arg:"subcommand:delete" help:"Delete a step"`
		Stats *struct {
			WorkflowId   *int32  `arg:"--workflow-id" help:"Workflow ID to get step stats for"`
			WorkflowName string  `arg:"--workflow-name" help:"Workflow name (alternative to ID, used to resolve ID)"`
			StepIds      []int32 `arg:"--step-id,separate" help:"Step IDs to get stats for (repeatable)"`
			TaskName     string  `arg:"--task-name" help:"Filter relevant step IDs by tasks whose name matches substring (case-insensitive, client-side)"`
			Totals       bool    `arg:"--totals" help:"Add totals line at the end of the stats"`
		} `arg:"subcommand:stats" help:"Show step statistics"`

		Edit *struct {
			StepId  int32  `arg:"--id,required" help:"Step ID"`
			Find    string `arg:"--find,required" help:"Text or regexp pattern to find in commands"`
			Replace string `arg:"--replace,required" help:"Replacement text"`
			Regexp  bool   `arg:"--regexp" help:"Treat --find as a regexp pattern"`
		} `arg:"subcommand:edit" help:"Find/replace in all failed tasks of a step and retry them"`
	} `arg:"subcommand:step" help:"Manage steps"`

	// File commands
	File *struct {
		RemoteList *struct {
			URI     string `arg:"positional,required" help:"URI to list files from (supports glob patterns)"`
			Timeout int    `arg:"--timeout" default:"30" help:"Timeout for listing files (in seconds)"`
		} `arg:"subcommand:remote-list" help:"List remote files"`
		Copy *struct {
			Src string `arg:"positional,required" help:"Source URI"`
			Dst string `arg:"positional,required" help:"Destination URI"`
		} `arg:"subcommand:copy" help:"Copy remote files"`

		List *struct {
			Src string `arg:"positional,required" help:"Source URI"`
		} `arg:"subcommand:list" help:"List remote files"`
	} `arg:"subcommand:file" help:"Remote file operations"`

	// (Workflow) Template commands
	Template *struct {
		Upload *struct {
			Path  string `arg:"--path,required" help:"Path to the Python template script"`
			Force bool   `arg:"--force" help:"Overwrite existing template with same name/version"`
		} `arg:"subcommand:upload" help:"Upload a new workflow template"`

		Run *struct {
			TemplateId   *int32  `arg:"--id" help:"ID of the template to run (either name or id is required)"`
			Name         *string `arg:"--name" help:"Name of the template to run (either name or id is required)"`
			Version      *string `arg:"--version" help:"Optional version (default to latest if omitted)"`
			ParamPairs   *string `arg:"--param" help:"Comma-separated key=value pairs (e.g. a=1,b=2)"`
			NoRecruiters bool    `arg:"--no-recruiters" help:"Create workflow without recruiters"`
		} `arg:"subcommand:run" help:"Run a workflow template"`

		List *struct {
			Name    *string `arg:"--name" help:"Template name (can include wildcards like 'meta%')"`
			Version *string `arg:"--version" help:"Template version (can be 'latest' or a wildcard)"`
			Latest  bool    `arg:"--latest" help:"Show only latest version(s) for each template name"`
		} `arg:"subcommand:list" help:"List all uploaded workflow templates"`

		Detail *struct {
			TemplateId *int32  `arg:"--id" help:"Show detailed information for this template ID (either name or id is required)"`
			Name       *string `arg:"--name" help:"Name of the template to show (either name or id is required)"`
			Version    *string `arg:"--version" help:"Optional version (default to latest if omitted)"`
		} `arg:"subcommand:detail" help:"Show a template's param JSON and metadata"`

		Download *struct {
			TemplateId *int32  `arg:"--id" help:"Template ID to download"`
			Name       *string `arg:"--name" help:"Name of the template to download"`
			Version    *string `arg:"--version" help:"Optional version (default to latest)"`
			Output     *string `arg:"--output,-o" help:"Output file path (default: stdout)"`
		} `arg:"subcommand:download" help:"Download a template script"`
	} `arg:"subcommand:template" help:"Manage workflow templates"`

	// Module commands
	Module *struct {
		Upload *struct {
			Path  string `arg:"--path,required" help:"Path to the module YAML file"`
			Force bool   `arg:"--force" help:"Overwrite existing module"`
		} `arg:"subcommand:upload" help:"Upload a private module to the server"`

		List *struct{} `arg:"subcommand:list" help:"List private modules on the server"`

		Download *struct {
			Name   string  `arg:"--name,required" help:"Module filename to download"`
			Output *string `arg:"--output,-o" help:"Output file path (default: stdout)"`
		} `arg:"subcommand:download" help:"Download a private module"`
	} `arg:"subcommand:module" help:"Manage private YAML modules"`

	// (Workflow) Template run commands
	Run *struct {
		List *struct {
			TemplateId *int32 `arg:"--template-id" help:"Filter runs by template ID"`
		} `arg:"subcommand:list" help:"List template runs"`

		Delete *struct {
			RunId int32 `arg:"--id,required" help:"ID of the template run to delete"`
		} `arg:"subcommand:delete" help:"Delete a template run"`
	} `arg:"subcommand:run" help:"Manage template runs"`

	// Login commands
	Login *struct {
		User     *string `arg:"--user" help:"Username to log in"`
		Password *string `arg:"--password" help:"Password to log in"`
	} `arg:"subcommand:login" help:"Login and provide a token, use with export SCITQ_TOKENs=$(scitq login)"`

	// Certificate command
	Cert *struct{} `arg:"subcommand:cert" help:"Print server TLS certificate (PEM)"`

	// HashPassword command
	HashPassword *struct {
		Password string `arg:"positional,required" help:"Password to hash"`
	} `arg:"subcommand:hashpassword" help:"Hash a password using bcrypt (useful for config files)"`

	// Worker event commands
	WorkerEvent *struct {
		List *struct {
			Limit    int    `arg:"--limit" default:"20" help:"Max number of events to show"`
			Level    string `arg:"--level" help:"Filter by level D/I/W/E as D:Debug/I:Info/W:Warning/E:Error"`
			Class    string `arg:"--class" help:"Filter by event_class"`
			WorkerId int32  `arg:"--worker-id" help:"Filter by worker id"`
		} `arg:"subcommand:list" help:"List worker events"`
		Delete *struct {
			Id int32 `arg:"--id,required" help:"Worker event ID to delete"`
		} `arg:"subcommand:delete" help:"Delete a worker event by ID"`
		Prune *struct {
			OlderThan string `arg:"--older-than" help:"Age to prune, e.g. 7d, 12h, 30m (required unless --dry-run)"`
			Level     string `arg:"--level" help:"Optional level filter D/I/W/E as D:Debug/I:Info/W:Warning/E:Error"`
			Class     string `arg:"--class" help:"Optional event_class filter"`
			WorkerId  int32  `arg:"--worker-id" help:"Optional worker id filter"`
			DryRun    bool   `arg:"--dry-run" help:"Only count matched rows; do not delete"`
		} `arg:"subcommand:prune" help:"Prune worker events by age and optional filters"`
	} `arg:"subcommand:worker-event" help:"Worker event logs"`
}

CLI struct encapsulates task & worker commands

func (Attr) Version

func (Attr) Version() string

Version enables go-arg's built-in --version handling. When users run `scitq --version`, go-arg will print this string and exit.

type CLI

type CLI struct {
	QC   lib.QueueClient
	Attr Attr
}

func (*CLI) ConfigImportRclone

func (c *CLI) ConfigImportRclone() error

ConfigImportRclone loads an rclone.conf and prints it as YAML fragment.

func (*CLI) Copy

func (c *CLI) Copy() error

func (*CLI) FileList

func (c *CLI) FileList() error

func (*CLI) FlavorList

func (c *CLI) FlavorList(limit int32, filter string) error

ListFlavors handles listing flavors.

func (*CLI) List

func (c *CLI) List() error

func (*CLI) ModuleDownload added in v0.7.1

func (c *CLI) ModuleDownload() error

func (*CLI) ModuleList added in v0.7.1

func (c *CLI) ModuleList() error

func (*CLI) ModuleUpload added in v0.7.1

func (c *CLI) ModuleUpload() error

func (*CLI) RecruiterCreate

func (c *CLI) RecruiterCreate() error

func (*CLI) RecruiterDelete

func (c *CLI) RecruiterDelete() error

func (*CLI) RecruiterList

func (c *CLI) RecruiterList() error

func (*CLI) RunDelete

func (c *CLI) RunDelete() error

func (*CLI) RunList

func (c *CLI) RunList() error

func (*CLI) StepCreate

func (c *CLI) StepCreate() error

func (*CLI) StepDelete

func (c *CLI) StepDelete() error

func (*CLI) StepEdit added in v0.7.1

func (c *CLI) StepEdit() error

StepEdit does find/replace on all failed tasks in a step and retries them.

func (*CLI) StepList

func (c *CLI) StepList() error

func (*CLI) StepStats

func (c *CLI) StepStats() error

StepStats implements the stats subcommand for steps.

func (*CLI) TaskCreate

func (c *CLI) TaskCreate() error

createTask sends a task creation request.

func (*CLI) TaskEdit added in v0.7.1

func (c *CLI) TaskEdit() error

TaskEdit edits a task's command and retries it.

func (*CLI) TaskList

func (c *CLI) TaskList() error

listTasks fetches and displays all tasks.

func (*CLI) TaskLogs added in v0.6.2

func (c *CLI) TaskLogs() error

TaskLogs streams both stdout and stderr of a task, with colors (blue for stdout, red for stderr).

func (*CLI) TaskRetry

func (c *CLI) TaskRetry() error

TaskRetry retries a failed task.

func (*CLI) TaskStderr added in v0.6.2

func (c *CLI) TaskStderr() error

TaskStderr streams stderr of a task by ID.

func (*CLI) TaskStdout added in v0.6.2

func (c *CLI) TaskStdout() error

TaskStdout streams stdout of a task by ID.

func (*CLI) TemplateDetail

func (c *CLI) TemplateDetail() error

func (*CLI) TemplateDownload added in v0.7.1

func (c *CLI) TemplateDownload() error

func (*CLI) TemplateList

func (c *CLI) TemplateList() error

func (*CLI) TemplateRun

func (c *CLI) TemplateRun() error

func (*CLI) TemplateUpload

func (c *CLI) TemplateUpload() error

func (*CLI) WithTimeout

func (cli *CLI) WithTimeout() (context.Context, context.CancelFunc)

WithTimeout provides a context with a timeout

func (*CLI) WorkerDelete

func (c *CLI) WorkerDelete() error

WorkerDelete deletes a worker instance.

func (*CLI) WorkerDeploy

func (c *CLI) WorkerDeploy() error

WorkerDeploy deploys a new worker instance.

func (*CLI) WorkerEventDelete

func (c *CLI) WorkerEventDelete() error

func (*CLI) WorkerEventList

func (c *CLI) WorkerEventList() error

func (*CLI) WorkerEventPrune

func (c *CLI) WorkerEventPrune() error

func (*CLI) WorkerList

func (c *CLI) WorkerList() error

ListWorkers handles listing workers

func (*CLI) WorkerStats

func (c *CLI) WorkerStats() error

func (*CLI) WorkerUpdate

func (c *CLI) WorkerUpdate() error

WorkerUpdate updates worker settings (user-scoped).

func (*CLI) WorkflowCreate

func (c *CLI) WorkflowCreate() error

func (*CLI) WorkflowDelete

func (c *CLI) WorkflowDelete() error

func (*CLI) WorkflowList

func (c *CLI) WorkflowList() error

func (*CLI) WorkflowUpdateStatus

func (c *CLI) WorkflowUpdateStatus() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL