From 6c0254895fda8e7c39b768ec29b103768bf93f8a Mon Sep 17 00:00:00 2001 From: William Melody Date: Wed, 1 Mar 2017 20:18:26 -0800 Subject: [PATCH] Support full `list` operations in `hosts` with no subcommand. --- README.md | 16 +++++++++++++++- hosts | 8 ++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f213b8..0abbe6b 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ curl -L https://raw.github.com/alphabetum/hosts/master/hosts \ ```text Usage: - hosts + hosts [] hosts add [] hosts block hosts disable ( | | ) @@ -81,6 +81,20 @@ hosts help ## Commands +## `hosts` + +```text +Usage: + hosts [] + +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 diff --git a/hosts b/hosts index 5895889..5a80737 100755 --- a/hosts +++ b/hosts @@ -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} [] ${_ME} add [] ${_ME} block ${_ME} disable ( | | )