Skip to content

ax ssh --help is parsed as a task name #373

Closed

Description

@zhoukuncheng

Summary

ax ssh --help does not print usage. The first positional argument is taken as the task name, so the command tries to fetch a task literally named --help:

$ ax ssh --help
Error: fetching task "--help": rpc error: code = NotFound desc = task "--help" not found in atespace "default"

ax --help and ax ssh (no args) behave as expected. AX d8ed0fe.

Suggested fix

The ssh subcommand parses its own flags before/after the task name (to support ax ssh <task> -- <cmd>); it should still honour -h/--help when it appears before the task name, either by letting cobra handle help or by checking for it explicitly before treating the argument as a task name.

Activity

  1. anzal1 commented on Sep 23, 2026

    @anzal1
    Contributor

    I have a fix for this on a branch since PRs look restricted to collaborators: https://github.com/anzal1/ax/tree/fix/ssh-arg-parsing (single commit, CLA signed).

    ax ssh -h/--help now prints ssh usage and exits 0, and a missing task name fails before the CLI resolves the server, so neither one starts a port-forward.

    While in there I found a related bug: the global flag loop in main() doesn't stop at --, so it eats flags meant for the remote command. ax ssh t -- grep -n foo file sets the namespace to foo and runs grep file, and ax ssh t -- ls -a /tmp switches the atespace to /tmp. The same commit makes parsing stop at -- and adds the first tests for cmd/ax.

    Happy to open it as a PR if you can enable that, or feel free to cherry-pick.

  2. self-assigned this
    on Sep 25, 2026
  3. added a commit that references this issue on Oct 15, 2026
    0126b72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions