Support full `list` operations in `hosts` with no subcommand.

This commit is contained in:
William Melody 2017-03-01 20:18:26 -08:00
parent 05ba7bdc03
commit 6c0254895f
2 changed files with 21 additions and 3 deletions

View File

@ -40,7 +40,7 @@ curl -L https://raw.github.com/alphabetum/hosts/master/hosts \
```text
Usage:
hosts
hosts [<search string>]
hosts add <ip> <hostname> [<comment>]
hosts block <hostname>
hosts disable (<ip> | <hostname> | <search string>)
@ -81,6 +81,20 @@ hosts help <command name>
## Commands
## `hosts`
```text
Usage:
hosts [<search string>]
Description:
List the existing IP / hostname pairs, optionally limited to a specified
state. When provided with a seach string, all matching enabled records will
be printed.
Alias for `hosts list`
```
## `hosts add`
```text

8
hosts
View File

@ -373,7 +373,11 @@ _main() {
# Pass all comment arguments to the program except for the first ($0).
${_CMD} "${_COMMAND_PARAMETERS[@]:-}"
else
_die printf "Unknown command: %s\n" "${_CMD}"
local _parameters=()
_parameters+=("${_CMD}")
_parameters+=(${_COMMAND_PARAMETERS[@]:-})
"${DEFAULT_COMMAND}" "${_parameters[@]:-}"
fi
}
@ -605,7 +609,7 @@ A program for managing host file entries.
Version: ${_VERSION}
Usage:
${_ME}
${_ME} [<search string>]
${_ME} add <ip> <hostname> [<comment>]
${_ME} block <hostname>
${_ME} disable (<ip> | <hostname> | <search string>)