From 2162f34d90a6d0ac4b2793ce8a278ac315cd654b Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Mon, 15 Feb 2016 18:34:25 +0900 Subject: [PATCH] One more push before 0.8.0, fixed bugs, paved the way for DEBUG mode. * Add Mizuki to THANKS for help with Japanese translation of the QuickStart Guide. * fisher --list should return 1 (fail) if no plugins are installed. Closes #101. * More consistent style 'Usage' instead of 'usage'. * Silence index check in case $fisher_cache/.index does not exist. * Add more descriptive message if plugin is not found. * Silence search failure in case $fisher_cache/.index does not exist. --- THANKS.md | 17 ++++++++--------- completions/fisher.fish | 12 +++++++----- functions/__fisher_list.fish | 8 +++++++- functions/fisher.fish | 6 ++---- functions/fisher_help.fish | 2 +- functions/fisher_install.fish | 4 ++-- functions/fisher_search.fish | 4 ++-- functions/fisher_uninstall.fish | 2 +- functions/fisher_update.fish | 2 +- man/man1/getopts.1 | 2 +- man/man1/getopts.md | 2 +- man/man7/fisher-commands.7 | 2 +- man/man7/fisher-commands.md | 2 +- man/man7/fisher-plugins.7 | 2 +- man/man7/fisher-plugins.md | 2 +- test/fisher.fish | 6 +++--- test/fixtures/help/usage.txt | 10 +++++----- test/help-parse.fish | 4 ++-- 18 files changed, 47 insertions(+), 42 deletions(-) diff --git a/THANKS.md b/THANKS.md index 919c73e..db1b44c 100644 --- a/THANKS.md +++ b/THANKS.md @@ -1,12 +1,11 @@ # Thank You -The following individuals have contributed to Fisherman. +The following individuals have contributed to Fisherman. :heart: -* Daniel Perez @tuvistavie -* Daniele Sluijters @daenney -* Hyeon Kim @simnalamburt -* Ian @ViViDboarder -* Jorge Bucaran @bucaran -* Kevin Ballard @kballard - -:heart: +* [Daniel Perez](https://github.com/tuvistavie) +* [Daniele Sluijters](https://github.com/daenney) +* [Hyeon Kim](https://github.com/simnalamburt) +* [Ian](https://github.com/ViViDboarder) +* [Jorge Bucaran](https://github.com/bucaran) +* [Kevin Ballard](https://github.com/kballard) +* [Mizuki Fujiwara](https://github.com/zukif) diff --git a/completions/fisher.fish b/completions/fisher.fish index f95aca7..0ca2e58 100644 --- a/completions/fisher.fish +++ b/completions/fisher.fish @@ -27,10 +27,6 @@ for option in commands guides end end -if test ! -e $fisher_cache/.index - exit -end - set -l plugins ( if test -s $fisher_file __fisher_file < $fisher_file | __fisher_name @@ -38,7 +34,12 @@ set -l plugins ( ) begin - awk -F '\n' -v RS='' -v OFS=';' '/^ *#/ { next } { print $1, $3 }' $fisher_cache/.index + awk -F '\n' -v RS='' -v OFS=';' ' + + /^ *#/ { next } { print $1, $3 } + + ' $fisher_cache/.index ^ /dev/null + __fisher_cache_list end | sort -ut ';' -k1,1 | while read -l name info @@ -48,4 +49,5 @@ end | sort -ut ';' -k1,1 | while read -l name info else complete -c fisher -n "__fish_seen_subcommand_from i install" -a "$name" -d "$info" end + end diff --git a/functions/__fisher_list.fish b/functions/__fisher_list.fish index 169cd0e..09470c3 100644 --- a/functions/__fisher_list.fish +++ b/functions/__fisher_list.fish @@ -10,13 +10,19 @@ function __fisher_list -a source case "" all cache set -l enabled (__fisher_list $fisher_file) + set -l cache (__fisher_cache_list) + + if test -z "$cache" + return 1 + end + set -l legend " " if test -z "$enabled" set legend "" end - for i in (__fisher_cache_list) + for i in $cache if contains -- $i $enabled if test $i = "$fisher_prompt" printf "%s%s\n" ">" $i diff --git a/functions/fisher.fish b/functions/fisher.fish index 5008360..26e1008 100644 --- a/functions/fisher.fish +++ b/functions/fisher.fish @@ -59,9 +59,7 @@ function fisher -d "Fish Plugin Manager" eval "fisher_$value" (printf "%s\n" "'"$argv"'") case list - if not __fisher_list $value - return 1 - end + __fisher_list $value case version sed 's/^/fisher version /;q' $fisher_home/VERSION @@ -71,7 +69,7 @@ function fisher -d "Fish Plugin Manager" set value commands end - printf "usage: fisher [] [--list] [--version] [--help]\n\n" + printf "Usage: fisher [] [--list] [--version] [--help]\n\n" switch commands case $value diff --git a/functions/fisher_help.fish b/functions/fisher_help.fish index 5c937e8..fdbee42 100644 --- a/functions/fisher_help.fish +++ b/functions/fisher_help.fish @@ -33,7 +33,7 @@ function fisher_help -d "Show Help" set option help case h - printf "usage: fisher help [] [--all] [--guides] [--help]\n\n" + printf "Usage: fisher help [] [--all] [--guides] [--help]\n\n" printf " -a --all List available documentation\n" printf " -g --guides List available guides\n" diff --git a/functions/fisher_install.fish b/functions/fisher_install.fish index 2eefb04..1f33816 100644 --- a/functions/fisher_install.fish +++ b/functions/fisher_install.fish @@ -17,7 +17,7 @@ function fisher_install -d "Install Plugins" set stderr /dev/null case h - printf "usage: fisher install [] [--force] [--quiet] [--help]\n\n" + printf "Usage: fisher install [] [--force] [--quiet] [--help]\n\n" printf " -f --force Reinstall given plugin/s\n" printf " -q --quiet Enable quiet mode\n" @@ -72,7 +72,7 @@ function fisher_install -d "Install Plugins" else set total (math $total - 1) - printf "fisher: '%s' not found.\n" $item > $stderr + printf "fisher: '%s' not found or index out of date.\n" $item > $stderr end end diff --git a/functions/fisher_search.fish b/functions/fisher_search.fish index 2a0612e..3d5d836 100644 --- a/functions/fisher_search.fish +++ b/functions/fisher_search.fish @@ -61,7 +61,7 @@ function fisher_search -d "Search Plugins" set quiet 1 case h - printf "usage: fisher search [] [--and|--or] [--quiet] [--help]\n\n" + printf "Usage: fisher search [] [--and|--or] [--quiet] [--help]\n\n" printf " *-- Filter by url, name, info, author or tags\n" printf " -o --or Join query with OR operator\n" @@ -135,7 +135,7 @@ function fisher_search -d "Search Plugins" author = \$5 } - $query { print $fields } " $index | awk -v quiet=$quiet ' + $query { print $fields } " $index ^ /dev/null | awk -v quiet=$quiet ' !/^ *$/ { hasRecords = 1 } { if (quiet) { diff --git a/functions/fisher_uninstall.fish b/functions/fisher_uninstall.fish index 9fa3ccb..392e84b 100644 --- a/functions/fisher_uninstall.fish +++ b/functions/fisher_uninstall.fish @@ -17,7 +17,7 @@ function fisher_uninstall -d "Uninstall Plugins" set stderr /dev/null case h - printf "usage: fisher uninstall [] [--force] [--quiet] [--help]\n\n" + printf "Usage: fisher uninstall [] [--force] [--quiet] [--help]\n\n" printf " -f --force Delete copy from cache\n" printf " -q --quiet Enable quiet mode\n" diff --git a/functions/fisher_update.fish b/functions/fisher_update.fish index bd51c26..2ba0b82 100644 --- a/functions/fisher_update.fish +++ b/functions/fisher_update.fish @@ -18,7 +18,7 @@ function fisher_update -d "Update Plugins/Fisherman" set stderr /dev/null case h - printf "usage: fisher update [] [--quiet] [--help]\n\n" + printf "Usage: fisher update [] [--quiet] [--help]\n\n" printf " -q --quiet Enable quiet mode\n" printf " -h --help Show usage help\n" return diff --git a/man/man1/getopts.1 b/man/man1/getopts.1 index c602d5e..b7a4d90 100644 --- a/man/man1/getopts.1 +++ b/man/man1/getopts.1 @@ -106,7 +106,7 @@ function fish set flags $flags $value case h help - printf "usage: $_ [OPTIONS] [\-c command] [FILE [ARGUMENTS\.\.\.]]\en" + printf "Usage: $_ [OPTIONS] [\-c command] [FILE [ARGUMENTS\.\.\.]]\en" return case \e* diff --git a/man/man1/getopts.md b/man/man1/getopts.md index 28cd095..e9be656 100644 --- a/man/man1/getopts.md +++ b/man/man1/getopts.md @@ -78,7 +78,7 @@ function fish set flags $flags $value case h help - printf "usage: $_ [OPTIONS] [-c command] [FILE [ARGUMENTS...]]\n" + printf "Usage: $_ [OPTIONS] [-c command] [FILE [ARGUMENTS...]]\n" return case \* diff --git a/man/man7/fisher-commands.7 b/man/man7/fisher-commands.7 index 585c115..da8e0a8 100644 --- a/man/man7/fisher-commands.7 +++ b/man/man7/fisher-commands.7 @@ -79,7 +79,7 @@ The following example implements a command to retrieve plugin information and fo function fisher_info \-d "Display information about plugins" switch "$argv" case \-h \-\-help - printf "usage: fisher info name | URL [\.\.\.]\en\en" + printf "Usage: fisher info name | URL [\.\.\.]\en\en" printf " \-h \-\-help Show usage help\en" return end diff --git a/man/man7/fisher-commands.md b/man/man7/fisher-commands.md index cd5d646..4be8596 100644 --- a/man/man7/fisher-commands.md +++ b/man/man7/fisher-commands.md @@ -46,7 +46,7 @@ The following example implements a command to retrieve plugin information and fo function fisher_info -d "Display information about plugins" switch "$argv" case -h --help - printf "usage: fisher info name | URL [...]\n\n" + printf "Usage: fisher info name | URL [...]\n\n" printf " -h --help Show usage help\n" return end diff --git a/man/man7/fisher-plugins.7 b/man/man7/fisher-plugins.7 index ee99cf5..fa7df93 100644 --- a/man/man7/fisher-plugins.7 +++ b/man/man7/fisher-plugins.7 @@ -109,7 +109,7 @@ cat > wtc\.fish function wtc \-d "Generate a random commit message" switch "$argv" case \-h \-\-help - printf "usage: wtc [\-\-help]\en\en" + printf "Usage: wtc [\-\-help]\en\en" printf " \-h \-\-help Show usage help\en" return end diff --git a/man/man7/fisher-plugins.md b/man/man7/fisher-plugins.md index ed57233..b67fd3b 100644 --- a/man/man7/fisher-plugins.md +++ b/man/man7/fisher-plugins.md @@ -71,7 +71,7 @@ cat > wtc.fish function wtc -d "Generate a random commit message" switch "$argv" case -h --help - printf "usage: wtc [--help]\n\n" + printf "Usage: wtc [--help]\n\n" printf " -h --help Show usage help\n" return end diff --git a/test/fisher.fish b/test/fisher.fish index ea55232..8f04151 100644 --- a/test/fisher.fish +++ b/test/fisher.fish @@ -5,7 +5,7 @@ function -S setup function fisher_$mock_command if not set -q argv[1] - echo usage:... + echo Usage:... return 1 end awk $argv @@ -17,7 +17,7 @@ function -S teardown end test "$TESTNAME - Evaluate `fisher_' (sub) commands" - (fisher $mock_command) = usage:... + (fisher $mock_command) = Usage:... end test "$TESTNAME - Commands can read standard input" @@ -33,7 +33,7 @@ test "$TESTNAME - Handle \$fisher_alias aliases" end test "$TESTNAME - Display usage help" - (fisher | sed 1q) = "usage: fisher [] [--list] [--version] [--help]" + (fisher | sed 1q) = "Usage: fisher [] [--list] [--version] [--help]" end test "$TESTNAME - Display basic information about using the `help' command by default" diff --git a/test/fixtures/help/usage.txt b/test/fixtures/help/usage.txt index 9f2ff52..837184e 100644 --- a/test/fixtures/help/usage.txt +++ b/test/fixtures/help/usage.txt @@ -1,25 +1,25 @@ -usage: fisher update [] [--quiet] [--help] +Usage: fisher update [] [--quiet] [--help] -q --quiet Enable quiet mode -h --help Show usage help -usage: fisher uninstall [] [--force] [--quiet] [--help] +Usage: fisher uninstall [] [--force] [--quiet] [--help] -f --force Delete copy from cache -q --quiet Enable quiet mode -h --help Show usage help -usage: fisher search [] [--and|--or] [--quiet] [--help] +Usage: fisher search [] [--and|--or] [--quiet] [--help] *-- Filter by url, name, info, author or tags -o --or Join query with OR operator -a --and Join query with AND operator -q --quiet Enable quiet mode -h --help Show usage help -usage: fisher install [] [--force] [--quiet] [--help] +Usage: fisher install [] [--force] [--quiet] [--help] -f --force Reinstall given plugin/s -q --quiet Enable quiet mode -h --help Show usage help -usage: fisher help [] [--all] [--guides] [--help] +Usage: fisher help [] [--all] [--guides] [--help] -a --all List available documentation -g --guides List available guides diff --git a/test/help-parse.fish b/test/help-parse.fish index 5fbfdaa..f3b2c40 100644 --- a/test/help-parse.fish +++ b/test/help-parse.fish @@ -1,7 +1,7 @@ function -S setup function foo - printf "%s\n" "usage: foo [options] ..." - printf "%s\n" "options:" + printf "%s\n" "Usage foo [options] ..." + printf "%s\n" "Options:" printf "%s\n" " --version Show version" printf "%s\n" " -h --help Show help" end