feat: add info command for JSON host details

Adds a jq-friendly `sshm info` subcommand with host completion and documentation, and makes home directory resolution testable for backup path tests.
This commit is contained in:
David Ibia
2026-01-12 23:53:35 +01:00
parent 58a9e6f40f
commit 7d9b794ceb
6 changed files with 572 additions and 10 deletions

View File

@@ -268,6 +268,17 @@ sshm move my-server -c /path/to/custom/ssh_config
# Search for hosts (interactive filter)
sshm search
# Print machine-readable info (JSON) for scripting
sshm info prod-server
sshm info prod-server --pretty
# With a custom SSH config file
sshm -c /path/to/custom/ssh_config info prod-server
# Pipe to jq
sshm info prod-server | jq -r '.result.target.hostname'
sshm info prod-server | jq -r '.result.target.user'
# Show version information (includes update check)
sshm --version
@@ -275,6 +286,19 @@ sshm --version
sshm --help
```
### Host Info (JSON)
`sshm info <hostname>` prints a single JSON object to stdout so you can script against it with `jq`.
```bash
# Extract fields
sshm info prod-server | jq -r '.result.target.hostname'
sshm info prod-server | jq -r '.result.target.port'
# Check not-found (exit code 2)
sshm info does-not-exist | jq -r '.error.code'
```
### Shell Completion
SSHM supports shell completion for host names, making it easy to connect to hosts without typing full names: