Skip to content

[feature] Replace --add flag with an add subcommand #7

@JerryAgbesi

Description

@JerryAgbesi

What problem are you trying to solve?
Adding a host entry today is done via the root command with the --add <alias> flag plus a positional user@host[:port] target (e.g. skipper --add bastion ubuntu@10.0.0.1:22). This conflates two surfaces on the same command: the default root behavior (open the TUI and connect) and a one-shot write operation. It is awkward to discover from --help, harder to grow (future options like -i/identity-file, comments, overwrite semantics), and inconsistent with the mental model users have from tools like git or gh where write operations live under their own verb.

Proposed solution
Introduce a dedicated add subcommand that replaces --add entirely:

skipper add <alias> <user@host[:port]> [flags]
  • <alias> and <user@host[:port]> are required positionals.
  • Reuses existing connect.ParseTarget + sshconfig.AddHost plumbing.
  • Respects the existing -c, --config persistent flag for target config path.
  • Prints the same "added host …" confirmation line as today.
  • Remove the -a, --add root flag and its handling in cmd/root.go (runRoot's Changed("add") branch, the addAlias var, the addHost helper's tie-in).
  • Update README flag table and any help text/examples.

Alternatives considered

  • Keep --add and also add a subcommand (deprecation alias). Rejected: the project is pre-1.0 and adding both doubles the surface and docs.
  • Fold into an interactive "add" flow from the TUI. Out of scope for this issue — that can be a follow-up on top of the subcommand.

Additional context

  • Existing implementation: cmd/root.go (addHost, addAlias, flag registration in init), internal/sshconfig/writer.go (AddHost).
  • Tests: add coverage for the new add subcommand (happy path + missing alias + malformed target) and drop tests tied to the removed flag.
  • Breaking change for users of --add; call it out in the PR description and README.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions