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
46 changes: 43 additions & 3 deletions crates/minimal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ pub enum Command {
/// List sessions
//
// Deliberate exception to the `<noun> <verb>` convention (documented in
// docs/reference/cli.md): `min ls` is the highest-traffic command in the
// CLI and keeps its bare top-level form. Not an oversightdo not move it
// under `session`.
// docs/reference/cli.md): `min session list` is the canonical spelling,
// and `min ls` — the highest-traffic command in the CLIkeeps this bare
// top-level form as its visible alias. Not an oversight — do not remove it.
Ls(LsArgs),
/// Shut down the minimald daemon
//
Expand Down Expand Up @@ -163,6 +163,9 @@ pub struct SessionArgs {

#[derive(Debug, Subcommand)]
pub enum SessionCommand {
/// List sessions
#[command(visible_alias = "ls")]
List(LsArgs),
/// Activate (create) a new session
Activate(ActivateArgs),
/// Attach to an existing session
Expand Down Expand Up @@ -649,6 +652,7 @@ async fn run_command(cli: Cli) -> Result<(), anyhow::Error> {
Some(Command::Ls(args)) => cmd_ls(&cli.global_args, args).await,
Some(Command::Stop(args)) => cmd_stop(&cli.global_args, args).await,
Some(Command::Session(SessionArgs { command })) => match command {
SessionCommand::List(args) => cmd_ls(&cli.global_args, args).await,
SessionCommand::Activate(args) => cmd_activate(&cli.global_args, args).await,
SessionCommand::Attach(args) => cmd_attach(&cli.global_args, args).await,
SessionCommand::Destroy(args) => cmd_destroy(&cli.global_args, args).await,
Expand Down Expand Up @@ -2833,6 +2837,42 @@ mod tests {
assert!(!cli.global_args.use_minvmd());
}

/// `min session list` is the canonical `<noun> list` spelling of the
/// flagship list command; `min ls` (top-level) and `min session ls`
/// (noun-level) are visible aliases. All three parse to the same `LsArgs`,
/// so `--raw`/`--json` reach the one `cmd_ls` implementation identically.
#[test]
fn session_list_spellings_all_reach_ls() {
use clap::Parser as _;
let ls_args = |args: &[&str]| -> LsArgs {
match Cli::try_parse_from(args).unwrap().command {
Some(Command::Ls(a))
| Some(Command::Session(SessionArgs {
command: SessionCommand::List(a),
})) => a,
_ => panic!("expected an ls command for {args:?}"),
}
};

for spelling in [
["min", "session", "list"].as_slice(),
["min", "session", "ls"].as_slice(),
["min", "ls"].as_slice(),
] {
let a = ls_args(spelling);
assert!(
!a.raw && !a.json,
"{spelling:?} must default both flags off"
);
}

// `--raw`/`--json` are accepted on the canonical and the bare form alike.
let canonical = ls_args(&["min", "session", "list", "--raw", "--json"]);
assert!(canonical.raw && canonical.json);
let bare = ls_args(&["min", "ls", "--json"]);
assert!(bare.json && !bare.raw);
}

/// `repo_dir` and `minimal_dir` are global, so they must be accepted after
/// the subcommand — not just before it (#1039).
#[test]
Expand Down
10 changes: 6 additions & 4 deletions docs/reference/cli-min.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ These apply to every subcommand.

## Commands

### `ls`
### `session list` (aliases: `min ls`, `min session ls`)

```
min ls [--raw] [--json]
min session list [--raw] [--json]
```
Comment on lines 42 to 44

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a language identifier to the fenced block.

markdownlint-cli2 reports MD040 because line 42 opens a fenced block without a language. Use console or shell.

Proposed fix
-```
+```console
 min session list [--raw] [--json]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
min ls [--raw] [--json]
min session list [--raw] [--json]
```
🧰 Tools
🪛 markdownlint-cli2 (0.23.1)

[warning] 42-42: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reference/cli-min.md` around lines 42 - 44, Update the fenced code block
containing the “min session list” command to declare the console language,
resolving the markdownlint MD040 violation while preserving the command text.

Source: Linters/SAST tools


Lists sessions. `--raw` prints raw session IDs one per line for piping
Expand All @@ -49,8 +49,10 @@ JSON. When the daemon reports a shared resource pool, the table is headed
by a `RESOURCE POOL:` line (CPU cores, memory, and the number of sessions
sharing them); `--raw` omits it.

A deliberate exception to the `min <noun> <verb>` convention: `ls` is the
highest-traffic command in the CLI and keeps its bare top-level form.
`min ls` is the same command kept bare at the top level — a deliberate
exception to the `min <noun> <verb>` convention, since it is the
highest-traffic command in the CLI; `min session ls` is the noun-level alias.
All three spellings take the same flags and produce identical output.

### `session activate`

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ergonomic choices, not leftovers — do not "fix" them:

| Form | Why it stays |
|------|--------------|
| `min ls` | The highest-traffic command in the CLI; the break is not worth the consistency. |
| `min ls` | Visible top-level alias of the canonical `min session list`; the highest-traffic command keeps its bare form. |
| `min stop` | Acts on the daemon backend rather than any session, and is the daemon-lifecycle command people reach for. |
| `min init`, `min add`, `min update` | Passthroughs to the `mip` commands of the same name; keeping the spelling identical across the two CLIs beats the hierarchy. |

Expand Down