This commit is contained in:
Jorge Bucaran 2016-02-27 15:27:17 +09:00
parent 397240499f
commit bd92ed25f7
3 changed files with 23 additions and 143 deletions

View File

@ -74,6 +74,14 @@ Display index records where \fIfield\fR equals \fImatch\fR\. \fIfield\fR can be
Same as \fB\-\-<field>[=regex]\fR, but using Regular Expressions instead of exact matching\. Use \fB!~\fR to negate the query\.
.
.TP
\fB\-\-format=oneline|short|verbose|longline\fR
Use the given format to display search results\.
.
.TP
\fB\-\-no\-color\fR
Turn off color display\.
.
.TP
\fB\-a \-\-and\fR
Join the query with a logical AND operator\.
.
@ -90,24 +98,6 @@ Enable quiet mode\.
Show help\.
.
.SH "OUTPUT"
Search prints the result records in their original format by default\.
.
.IP "" 4
.
.nf
fisher search shark
shark
https://github\.com/bucaran/shark
Sparkline Generator
chart tool graph sparkline
bucaran
.
.fi
.
.IP "" 0
.
.P
To allow for easier parsing, Search will print results records in the same line when using one or more of the following options: \fB\-\-name\fR, \fB\-\-url\fR, \fB\-\-info\fR, \fB\-\-tags\fR, \fB\-\-author\fR\.
.
.IP "" 4
@ -143,7 +133,7 @@ fisher search \-\-name | column
.IP "" 0
.
.IP "\(bu" 4
Display plugins by URL, sans \fIhttps://github\.com/\fR and format into multiple columns\.
Display plugins by URL, remove \fIhttps://github\.com/\fR and format into multiple columns\.
.
.IP "" 0
.
@ -151,7 +141,7 @@ Display plugins by URL, sans \fIhttps://github\.com/\fR and format into multiple
.
.nf
fisher search \-\-field=url | sed \'s|https://github\.com/||\' | column
fisher search \-\-url | sed \'s|https://github\.com/||\' | column
.
.fi
.
@ -166,7 +156,7 @@ Display remote plugins, i\.e, those in the index, but \fInot\fR in the cache\.
.
.nf
fisher_search \-\-and \-\-name!=(fisher \-\-list=bare)
fisher search \-\-and \-\-name!=(fisher \-\-list=bare)
.
.fi
.

View File

@ -4,13 +4,10 @@
.TH "GETOPTS" "1" "February 2016" "" "fisherman"
.
.SH "NAME"
\fBgetopts\fR \- Parse CLI options
\fBgetopts\fR \- Command line options parser
.
.SH "SYNOPSIS"
\fBgetopts\fR [\fIoptions\fR \.\.\.]
.
.br
\fBgetopts\fR [\fIoptions\fR \.\.\.] \fB|\fR \fBwhile\fR read \-l key value; \.\.\.; \fBend\fR
getopts \fIoptions\fR \.\.\.
.
.br
.
@ -18,7 +15,7 @@
\fBGetopts\fR is a command line options parser for fish\.
.
.SH "USAGE"
The best way to understand how getopts work is by studying a basic example\.
Study the output of the following example
.
.IP "" 4
.
@ -30,9 +27,6 @@ getopts \-ab1 \-\-foo=bar baz
.
.IP "" 0
.
.P
And its output\.
.
.IP "" 4
.
.nf
@ -47,10 +41,10 @@ _ baz
.IP "" 0
.
.P
The items on the left represent the option flags or \fIkeys\fR associated with the CLI\. The items on the right are the option \fIvalues\fR\. The underscore \fB_\fR character is the default \fIkey\fR for arguments without a key\.
The items on the left are the option flags\. The items on the right are the option values\. The underscore \fB_\fR character is the default \fIkey\fR for bare arguments\.
.
.P
Use read(1) to process the generated stream and switch(1) to match patterns:
Use read(1) to process the generated stream and switch(1) to match patterns
.
.IP "" 4
.
@ -69,62 +63,10 @@ end
.
.IP "" 0
.
.SH "EXAMPLES"
The following is a mock of fish(1) CLI\.
.
.IP "" 4
.
.nf
function fish
set \-l mode
set \-l flags
set \-l commands
set \-l debug_level
getopts $argv | while read \-l key value
switch $key
case c command
set commands $commands $value
case d debug\-level
set debug_level $value
case i interactive
set mode $value
case l login
set mode $value
case n no\-execute
set mode $value
case p profile
set flags $flags $value
case h help
printf "Usage: $_ [OPTIONS] [\-c command] [FILE [ARGUMENTS\.\.\.]]\en"
return
case \e*
printf "$_: \'%s\' is not a valid option\.\en" $key
return 1
end
end
# Implementation
end
.
.fi
.
.IP "" 0
.
.SH "NOTES"
.
.IP "\(bu" 4
A double dash, \fB\-\-\fR, marks the end of options\. Arguments after this sequence are placed in the default underscore key, \fB_\fR\.
.
.IP "" 0
.
.SH "AUTHORS"
Jorge Bucaran \fIj@bucaran\.me\fR\.

View File

@ -1,10 +1,9 @@
getopts(1) -- Parse CLI options
===============================
getopts(1) -- Command line options parser
=========================================
## SYNOPSIS
`getopts` [*options* ...]<br>
`getopts` [*options* ...] `|` `while` read -l key value; ...; `end`<br>
getopts *options* ...<br>
## DESCRIPTION
@ -12,14 +11,12 @@ getopts(1) -- Parse CLI options
## USAGE
The best way to understand how getopts work is by studying a basic example.
Study the output of the following example
```
getopts -ab1 --foo=bar baz
```
And its output.
```
a
b 1
@ -27,9 +24,9 @@ foo bar
_ baz
```
The items on the left represent the option flags or *keys* associated with the CLI. The items on the right are the option *values*. The underscore `_` character is the default *key* for arguments without a key.
The items on the left are the option flags. The items on the right are the option values. The underscore `_` character is the default *key* for bare arguments.
Use read(1) to process the generated stream and switch(1) to match patterns:
Use read(1) to process the generated stream and switch(1) to match patterns
```
getopts -ab1 --foo=bar baz | while read -l key option
@ -42,55 +39,6 @@ getopts -ab1 --foo=bar baz | while read -l key option
end
```
## EXAMPLES
The following is a mock of fish(1) CLI.
```
function fish
set -l mode
set -l flags
set -l commands
set -l debug_level
getopts $argv | while read -l key value
switch $key
case c command
set commands $commands $value
case d debug-level
set debug_level $value
case i interactive
set mode $value
case l login
set mode $value
case n no-execute
set mode $value
case p profile
set flags $flags $value
case h help
printf "Usage: $_ [OPTIONS] [-c command] [FILE [ARGUMENTS...]]\n"
return
case \*
printf "$_: '%s' is not a valid option.\n" $key
return 1
end
end
# Implementation
end
```
## NOTES
* A double dash, `--`, marks the end of options. Arguments after this sequence are placed in the default underscore key, `_`.
## AUTHORS
Jorge Bucaran <j@bucaran.me>.