Skip to main content

start_command/
usage.rs

1/// Print usage information
2pub fn print_usage() {
3    println!(
4        r#"Usage: start [options] [--] <command> [args...]
5       start <command> [args...]
6       start --status <uuid> [--output-format <format>]
7       start --list [--running] [--output-format <format>]
8       start --upload-log <uuid-or-session-name>
9       start --stop <uuid-or-session-name>
10       start --terminate <uuid-or-session-name>
11       start --attach <uuid-or-session-name> [--read-only]
12       start --resume <uuid-or-session-name> [-- <command>]
13       start --resume-all [--output-format <format>]
14
15Options:
16  --help, -h           Show this usage and exit successfully
17  --isolated, --isolation, -i <env>  Run in isolated environment (screen, tmux, docker, ssh)
18  --attached, -a        Run in attached mode (foreground)
19  --detached, -d        Run in detached mode (background)
20  --session, -s <name>  Session name for isolation
21  --session-id <uuid>   Session UUID for tracking (auto-generated if not provided)
22  --session-name <uuid> Alias for --session-id
23  --image <image>       Docker image (optional, defaults to OS-matched image)
24  --volume, -v <spec>   Docker bind mount/volume host:container[:mode] (repeatable, docker only)
25  --mount <spec>        Docker --mount spec (repeatable, docker only)
26  --env, -e <KEY=VALUE> Environment variable for docker container (repeatable, docker only)
27  --label <KEY=VALUE>   Container attribution (repeatable, docker only; start-command.* reserved)
28  --privileged          Run docker container in privileged mode (docker only)
29  --network <name>      Connect to a named network (repeatable, docker only)
30  --network-alias <alias> Add alias to the first network (repeatable, docker only)
31  --on-kill-resume <N>  Resume a killed (exit 137 / OOM) detached docker session up to N times
32  --recovery-command <cmd>  Command to run in the same container on such a resume
33  --on-kill-resume-delay <min[-max]>  Wait a random number of seconds before each such resume (default 0)
34  --memory <size|N%|MIN%-MAX%>  Docker RAM cap; percentages use daemon capacity
35  --memory-swap <spec>  Combined memory+swap cap (defaults to memory, no extra swap)
36  --cpus <n|N%|MIN%-MAX%>  Docker CPU cap; ranges draw once per creation
37  --on-kill-resume-memory <spec>  New memory cap before a qualifying OOM recovery
38  --cpu-penalty        Enable delayed Docker CPU penalty (default off)
39  --cpu-penalty-cpus <n>  Penalty cap (default 2 CPUs)
40  --cpu-penalty-trigger <p%>  Busy threshold (default 95% of usable CPUs)
41  --cpu-penalty-trigger-window <d>  Fully covered busy window (default 15m)
42  --cpu-penalty-release <p%>  Quiet threshold (default 65% of penalty cap)
43  --cpu-penalty-release-window <d>  Minimum quiet/capped window (default 15m)
44                        Durations accept ms, s, m, h; --status reports penalty state
45  --endpoint <endpoint> SSH endpoint (required for ssh isolation, e.g., user@host)
46  --isolated-user, -u [name]  Create isolated user with same permissions
47  --keep-user           Keep isolated user after command completes
48  --keep-alive, -k      Keep isolation environment alive after command exits
49  --auto-remove-docker-container  Always remove docker container after exit (compatibility alias)
50  --always-cleanup-container  Always remove docker container after exit
51  --keep-container     Keep docker container filesystem after exit
52  --keep-container-on-fail  Remove successful docker containers, keep failed or OOM-killed ones
53  --shell <shell>       Shell to use in isolation environments: auto, bash, zsh, sh (default: auto)
54  --use-command-stream  Use command-stream library for execution (experimental)
55  --status <id>         Show status of execution by UUID or session name (--output-format: links-notation|json|text)
56  --list                List all tracked executions (--output-format: links-notation|json|text)
57  --running             With --list, only report executions that are still running
58  --upload-log <id>     Upload a sanitized copy of the stored log privately
59  --no-sanitize        With --upload-log, explicitly upload without secret redaction
60  --stop <id>           Ask a detached isolated execution to stop gracefully
61  --terminate <id>      Terminate a detached isolated execution immediately
62  --attach <id>         Attach to a running detached isolated execution
63  --read-only           With --attach, follow output without sending input
64  --resume <id>         Restart a stopped detached execution in the same environment
65                        (append -- <command> to run a different command there)
66  --remove-original    With legacy snapshot resume, remove the stopped original after launch
67  --remove-original-after <s>  Remove it only if the replacement still runs after <s> seconds
68  --snapshot-wait <s>   Wait up to <s> seconds for another snapshot on this host (exit 75 after)
69  --snapshot-disk-wait <s>  Wait up to <s> seconds for free disk instead of refusing (exit 75 after)
70  --snapshot-size-hint <bytes>  Use this writable-layer size instead of docker inspect --size
71  --snapshot-prepare <cmd>  docker exec <cmd> in the started original before it is snapshotted
72  --resume-all          Re-attach or reconcile every execution still marked running
73  --cleanup             Clean up stale "executing" records (crashed/killed processes)
74  --cleanup-dry-run     Show stale records that would be cleaned up (without cleaning)
75  --cleanup <id>        Remove a Docker execution's containers and snapshot images (never forced)
76  --cleanup-dry-run <id>  Show the containers and images --cleanup <id> would remove
77  --version, -v         Show version information
78
79Examples:
80  start echo "Hello World"
81  start bun test
82  start --isolated tmux -- bun start
83  start -i screen -d bun start
84  start --isolated docker -- echo 'hi'  # uses OS-matched default image
85  start --isolated docker --image oven/bun:latest -- bun install
86  start -i docker -v ~/.config/gh:/root/.config/gh -e TOKEN=abc -- gh repo list
87  start -i docker --image konard/hive-mind-dind:latest --privileged -- solve ...
88  start --isolated ssh --endpoint user@remote.server -- ls -la
89  start --isolated-user -- npm test
90  start -u myuser -- npm start
91  start -i screen --isolated-user -- npm test
92  start --status a1b2c3d4-e5f6-7890-abcd-ef1234567890
93  start --status a1b2c3d4 --output-format json
94  start --list
95  start --list --output-format json
96  start --list --running
97  start --upload-log my-screen-session
98  start --stop my-screen-session
99  start --terminate my-screen-session
100  start --attach my-docker-session
101  start --attach my-docker-session --read-only
102  start --resume my-docker-session
103  start --resume my-docker-session -- bash
104  start --resume-all
105  start -i docker -d --on-kill-resume 3 --recovery-command 'solve --resume' -- solve
106  start -i docker -d --on-kill-resume 3 --on-kill-resume-delay 30-90 -- cargo test
107  start --cleanup-dry-run
108  start --cleanup
109
110Features:
111  - Logs all output to temporary directory
112  - Displays timestamps and exit codes
113  - Auto-reports failures for NPM packages (when gh is available)
114  - Natural language command aliases (via substitutions.lino)
115  - Process isolation via screen, tmux, or docker"#
116    );
117}