mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2026-03-14 03:41:27 +01:00
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:
24
README.md
24
README.md
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user