Simplify fisher_help, update docs.

This commit is contained in:
Jorge Bucaran 2016-03-09 18:40:59 +09:00
parent cf26f815b1
commit 732744c062
No known key found for this signature in database
GPG key ID: E54BA3C0E646DB30
11 changed files with 77 additions and 207 deletions

View file

@ -36,16 +36,10 @@ curl -sL get.fisherman.sh | fish
The Fisherman CLI consists of the following commands: *install*, *update*, *uninstall*, *list*, *search* and *help*.
Fisherman knows the following aliases too: *i* for install, *u* for update, *l* for list, *s* for search and *h* for help.
Fisherman knows the following aliases: *i* for install, *u* for update, *l* for list, *s* for search and *h* for help.
### Examples
* Update Fisherman.
```fish
fisher update
```
* Install plugins.
```fish
@ -70,6 +64,12 @@ fisher install owner/repo
fisher install gist.github.com/owner/1f40e1c6e0551b2666b2
```
* Update Fisherman.
```fish
fisher update
```
* Update plugins.
```fish
@ -270,8 +270,8 @@ This file is automatically updated as you install and uninstall plugins.
* $fisher_cache<br>
The cache directory. Plugins are downloaded to this location.
* $fisher_alias *command*=*alias*[,*alias2*] ...<br>
Use this variable to customize Fisherman command aliases.
* $fisher_alias *command*=*alias* ...<br>
Use this variable to create aliases of Fisherman commands.
## Plugins

View file

@ -25,26 +25,14 @@ function fisher -d "Fish plugin manager"
switch "$option"
case command
switch "$version"
case 2.1.\* 2.0.0
if test ! -z "$fisher_alias"
printf "fisher: fish 2.2.0 or above is required to use aliases."
end
set -l IFS =
set -l default_alias install=i update=u search=s list=l help=h new=n
case \*
if test -z "$fisher_alias"
set -g fisher_alias install=i update=u search=s list=l help=h
end
printf "%s\n" $fisher_alias | sed 's/[=,]/ /g' | while read -la alias
if set -q alias[2]
switch "$value"
case $alias[2..-1]
set value $alias[1]
break
end
end
end
printf "%s\n" $fisher_alias $default_alias | while read -l command alias
if test "$value" = "$alias"
set value "$command"
break
end
end
if not functions -q "fisher_$value"
@ -66,21 +54,27 @@ function fisher -d "Fish plugin manager"
sed 's/^/fisher version /' $fisher_home/VERSION
case help
printf "Usage: fisher <command> [<arguments>] [--help] [--version]\n\n"
printf "Usage: fisher <command> [<options>] [--help] [--version]\n\n"
set -l color (set_color $fish_color_command -u)
set -l color_normal (set_color normal)
printf "Available Commands:\n"
printf "Commands:\n"
fisher_help --commands=bare | sed -E "
s/ (h)/ $color\1$color_normal/
s/ (i)/ $color\1$color_normal/
s/ (l)/ $color\1$color_normal/
s/ (s)/ $color\1$color_normal/
s/ (u)p/ $color\1$color_normal"p"/
"
__fisher_help_commands | sed "
printf "\nUse fisher help <command> to access a man page.\n"
s/^/ /
s/;/"\t" /
" | column -ts\t | sed -E "
s/^ (h)(elp)/ $color\1$color_normal\2/
s/^ (i)(nstall)/ $color\1$color_normal\2/
s/^ (s)(earch)/ $color\1$color_normal\2/
s/^ (u)(pdate)/ $color\1$color_normal\2/
s/^ (l)(ist)/ $color\1$color_normal\2/
s/^ (n)(ew)/ $color\1$color_normal\2/
"
printf "\nUse fisher help <command> to get help.\n"
end
end

View file

@ -13,16 +13,12 @@ function fisher_help -d "Show help"
set option man
set value $2
case commands
set option $option commands
set value $2
case usage
set option usage
set value $value $2
case h
printf "Usage: fisher help [<keyword>] [--help]\n"
printf "Usage: fisher help [<keyword>]\n"
return
case \*
@ -32,10 +28,6 @@ function fisher_help -d "Show help"
end
end
if not set -q option[1]
set option commands
end
switch "$option"
case man
set -l value (printf "%s\n" $value | awk '{ print tolower($0) }')
@ -50,15 +42,5 @@ function fisher_help -d "Show help"
case usage
__fisher_help_usage $value
case \*
if test "$value" != bare
fisher --help=$option
return
end
if contains -- commands $option
__fisher_help_commands
end | sed 's/^/ /;s/;/'\t'/' | column -ts\t
end
end

View file

@ -1,13 +1,13 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "FISHER\-HELP" "1" "February 2016" "" "fisherman"
.TH "FISHER\-HELP" "1" "March 2016" "" "fisherman"
.
.SH "NAME"
\fBfisher\-help\fR \- Show help about Fisherman
.
.SH "SYNOPSIS"
fisher help [\fIkeyword\fR] [\-\-all] [\-\-guides] [\-\-usage[=\fIcommand\fR]] [\-\-help]
fisher help [\fIcommand\fR] [\-\-help]
.
.br
.
@ -15,12 +15,6 @@ fisher help [\fIkeyword\fR] [\-\-all] [\-\-guides] [\-\-usage[=\fIcommand\fR]] [
fisher help \fIcommand\fR
.
.br
fisher help \fIguide\fR
.
.br
fisher help \-\-usage=[\fIcommand\fR]
.
.br
.
.SH "DESCRIPTION"
Help displays \fIcommand\fR documentation, usage, guides and tutorials\.
@ -51,71 +45,8 @@ There are utilities that can help you generate man pages from other text formats
.SH "OPTIONS"
.
.TP
\-a, \-\-all
List all available commands and guides\.
.
.TP
\-g, \-\-guides[=\fIbare\fR]
List guides / tutorials\. Use \fIbare\fR to generate easy to parse output\.
.
.TP
\-\-commands[=\fIbare\fR]
List commands\. This is the default behavior of fisher help\. Use \fIbare\fR to generate easy to parse output\.
.
.TP
\-\-usage[=\fIcommand\fR]
Display usage help for \fIcommand\fR\. To teach Fisherman how to display help for your command, \fIcommand\fR must implement a \-h flag\.
.
.TP
\-h, \-\-help
Show usage help\.
.
.SH "EXAMPLES"
.
.IP "\(bu" 4
Show all the existing documentation\.
.
.IP "" 0
.
.IP "" 4
.
.nf
fisher help \-\-all
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
Show help about help\.
.
.IP "" 0
.
.IP "" 4
.
.nf
fisher help help
.
.fi
.
.IP "" 0
.
.IP "\(bu" 4
Show usage help for all available commands\.
.
.IP "" 0
.
.IP "" 4
.
.nf
fisher help \-\-commands=bare | fisher help \-\-usage
.
.fi
.
.IP "" 0
.
.SH "SEE ALSO"
man(1), fisher(1)

View file

@ -3,13 +3,11 @@ fisher-help(1) -- Show help about Fisherman
## SYNOPSIS
fisher help [*keyword*] [--all] [--guides] [--usage[=*command*]] [--help]<br>
fisher help [*command*] [--help]<br>
## USAGE
fisher help *command*<br>
fisher help *guide*<br>
fisher help --usage=[*command*]<br>
## DESCRIPTION
@ -31,41 +29,9 @@ There are utilities that can help you generate man pages from other text formats
## OPTIONS
* -a, --all:
List all available commands and guides.
* -g, --guides[=*bare*]:
List guides / tutorials. Use *bare* to generate easy to parse output.
* --commands[=*bare*]:
List commands. This is the default behavior of fisher help. Use *bare* to generate easy to parse output.
* --usage[=*command*]:
Display usage help for *command*. To teach Fisherman how to display help for your command, *command* must implement a -h flag.
* -h, --help:
Show usage help.
## EXAMPLES
* Show all the existing documentation.
```
fisher help --all
```
* Show help about help.
```
fisher help help
```
* Show usage help for all available commands.
```
fisher help --commands=bare | fisher help --usage
```
## SEE ALSO
man(1), fisher(1)

View file

@ -7,7 +7,7 @@
\fBfisher\fR \- Fish plugin manager
.
.SH "SYNOPSIS"
fisher \fIcommand\fR [\fIarguments\fR] [\-\-version] [\-\-help]
fisher \fIcommand\fR [\fIoptions\fR] [\-\-version] [\-\-help]
.
.br
.
@ -24,7 +24,7 @@ Run a command\.
.
.nf
fisher <command> [<arguments>]
fisher <command> [<options>]
.
.fi
.
@ -44,7 +44,7 @@ fisher help <command>
.IP "" 0
.
.P
Fisherman knows the following too: \fIi\fR for install, \fIu\fR for update, \fIl\fR for list, \fIs\fR for search and \fIh\fR for help\.
Fisherman knows the following aliases: \fIi\fR for install, \fIu\fR for update, \fIl\fR for list, \fIs\fR for search and \fIh\fR for help\.
.
.SH "OPTIONS"
.
@ -57,19 +57,6 @@ Show version information\. Fisherman follows Semantic Versioning and uses Git an
Show usage help\.
.
.SH "EXAMPLES"
Update Fisherman\.
.
.IP "" 4
.
.nf
fisher update
.
.fi
.
.IP "" 0
.
.P
Install plugins\.
.
.IP "" 4
@ -122,6 +109,19 @@ fisher install gist\.github\.com/owner/1f40e1c6e0551b2666b2
.IP "" 0
.
.P
Update Fisherman\.
.
.IP "" 4
.
.nf
fisher update
.
.fi
.
.IP "" 0
.
.P
Update plugins\.
.
.IP "" 4
@ -447,8 +447,8 @@ $fisher_cache
The cache directory\. Plugins are downloaded to this location\.
.
.TP
$fisher_alias \fIcommand\fR=\fIalias\fR[,\fIalias2\fR] \.\.\.
Use this variable to customize Fisherman command aliases\.
$fisher_alias \fIcommand\fR=\fIalias\fR \.\.\.
Use this variable to create aliases of Fisherman commands\.
.
.SH "PLUGINS"
Plugins can be utilities, prompts, commands or snippets\.

View file

@ -3,7 +3,7 @@ fisher(1) -- Fish plugin manager
## SYNOPSIS
fisher *command* [*arguments*] [--version] [--help]<br>
fisher *command* [*options*] [--version] [--help]<br>
## DESCRIPTION
@ -16,7 +16,7 @@ The CLI consists of the following commands: *install*, *update*, *uninstall*, *l
Run a command.
```
fisher <command> [<arguments>]
fisher <command> [<options>]
```
Get help about a command.
@ -25,7 +25,7 @@ Get help about a command.
fisher help <command>
```
Fisherman knows the following too: *i* for install, *u* for update, *l* for list, *s* for search and *h* for help.
Fisherman knows the following aliases: *i* for install, *u* for update, *l* for list, *s* for search and *h* for help.
## OPTIONS
@ -37,12 +37,6 @@ Fisherman knows the following too: *i* for install, *u* for update, *l* for list
## EXAMPLES
Update Fisherman.
```fish
fisher update
```
Install plugins.
```fish
@ -67,6 +61,12 @@ Install a plugin from a Gist URL.
fisher install gist.github.com/owner/1f40e1c6e0551b2666b2
```
Update Fisherman.
```fish
fisher update
```
Update plugins.
```
@ -266,8 +266,8 @@ This file is automatically updated as you install and uninstall plugins.
* $fisher_cache:
The cache directory. Plugins are downloaded to this location.
* $fisher_alias *command*=*alias*[,*alias2*] ...:
Use this variable to customize Fisherman command aliases.
* $fisher_alias *command*=*alias* ...:
Use this variable to create aliases of Fisherman commands.
## PLUGINS

View file

@ -1,7 +1,7 @@
set -l mock_command awk
function -S setup
set -g fisher_alias "$mock_command=A,B"
set -g fisher_alias "$mock_command=A"
function fisher_$mock_command
if not set -q argv[1]
@ -29,17 +29,20 @@ test "$TESTNAME - Display version information"
end
test "$TESTNAME - Handle \$fisher_alias aliases"
(fisher A; fisher B) = (fisher $mock_command; fisher $mock_command)
(fisher A) = (
fisher $mock_command
fisher $mock_command
)
end
test "$TESTNAME - Display usage help"
(fisher | sed 1q) = "Usage: fisher <command> [<arguments>] [--help] [--version]"
(fisher | sed 1q) = "Usage: fisher <command> [<options>] [--help] [--version]"
end
test "$TESTNAME - Display basic information help info about 'help'"
(fisher | tail -n2 | xargs) = "Use fisher help <command> to access a man page."
(fisher | tail -n2 | xargs) = "Use fisher help <command> to get help."
end
test "$TESTNAME - Display basic information about available commands"
(fisher | sed -E 's/ +//' | grep "^$mock_command\$")
(fisher | sed -E 's/^[ ]+//' | grep "^$mock_command")
end

View file

@ -28,4 +28,4 @@ Usage: fisher install [<plugins>] [--force] [--quiet] [--help]
-f --force Reinstall given plugin/s
-q --quiet Enable quiet mode
-h --help Show usage help
Usage: fisher help [<keyword>] [--help]
Usage: fisher help [<keyword>]

View file

@ -28,5 +28,7 @@ for i in $sections
end
test "$TESTNAME - Display usage help for every command"
(cat $DIRNAME/fixtures/help/usage.txt) = (fisher help --commands=bare | fisher help --usage)
(cat $DIRNAME/fixtures/help/usage.txt) = (
__fisher_help_commands | cut -f1 -d \; | fisher help --usage
)
end

View file

@ -1,8 +0,0 @@
# We need to iterate over each page because piping to | xargs man will use
# the system `man` instead of our fish-only wrapper.
for page in (fisher help --commands=bare | awk '{ print "fisher-"$1 }')
test "$TESTNAME - Wrap man and add fisherman to MANPATH to display fisher docs"
"$page(1)" = (man $page | awk '{ print tolower($1); exit }')
end
end