Skip to content

feat(cli): exec and logs pick a lease when you do not name one - #395

Merged
jleni merged 1 commit into
mainfrom
feat/cli-picker-exec-logs-portforward
Sep 25, 2026
Merged

jleni merged 1 commit into
mainfrom
feat/cli-picker-exec-logs-portforward

Conversation

@jleni

@jleni jleni commented Sep 25, 2026

Copy link
Copy Markdown
Member

Finishes what #387 started for vnc. kobe exec and kobe logs take
[LEASE]: with one lease that can serve the verb it is used, with several you
pick from a list, with none you are told so. Only leases advertising the verb
are offered.

$ kobe exec -- uname -a          # one exec-capable lease: used
$ kobe logs                      # several: picker
$ kobe exec -- uname -a          # none: "No active lease supports `exec`"

Non-interactive callers are unaffected — #387 put the terminal check inside
run_picker, so a script or an agent gets the candidates and how to name one
rather than a hang.

port-forward cannot join them

Not a decision — clap rejects it:

Found non-required positional argument with a lower index than a required
positional argument: "lease" index Some(1)

spec is a positional that follows the lease. Making the lease optional needs
spec to become a flag or the two to swap places, and both break a command
line people already use. Recorded on the field so the next person does not
rediscover it by hitting the assert at runtime.

exec works because -- already separates its trailing command:
kobe exec [OPTIONS] [LEASE] -- <COMMAND>....

Left out deliberately

cancel still requires its lease. A picker there means one mis-aimed keypress
cancels a lease, so it wants a decision on confirmation first.

Verification

213 unit + 48 integration tests, clippy -p kobectl --all-targets --all-features -D warnings clean. --help checked for all three:

kobe exec [OPTIONS] [LEASE] -- <COMMAND>...
kobe logs [OPTIONS] [LEASE]
kobe port-forward [OPTIONS] <LEASE> <SPEC>

Finishes what #387 started for `vnc`. `kobe exec` and `kobe logs` take
`[LEASE]`: with one lease that can serve the verb it is used, with several you
pick from a list, with none you are told so. Only leases advertising the verb
are offered.

`port-forward` cannot join them, and the reason is structural rather than a
decision: `spec` is a positional that follows the lease, and clap rejects an
optional positional before a required one —

    Found non-required positional argument with a lower index than a required
    positional argument: "lease" index Some(1)

Making it optional needs `spec` to become a flag or the two to swap places,
and both break a command line people already use. That is recorded on the
field so the next person does not rediscover it by hitting the assert.

`exec` works because `--` already separates its trailing command:
`kobe exec [OPTIONS] [LEASE] -- <COMMAND>...`.
@jleni
jleni merged commit baae0a1 into main Sep 25, 2026
11 checks passed
@jleni
jleni deleted the feat/cli-picker-exec-logs-portforward branch September 25, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant