mirror of https://github.com/jorgebucaran/fisher
commit
8bfdf82171
@ -1,2 +1,3 @@
|
||||
# Authors
|
||||
* Jorge Bucaran <[j@bucaran.me](mailto:j@bucaran.me)>
|
||||
* Hyeon Kim <[simnalamburt@gmail.com](mailto:simnalamburt@gmail.com)>
|
||||
|
@ -0,0 +1,35 @@
|
||||
function __fisher_alias -a value -d "Define one or more comma-separated command aliases."
|
||||
switch "$value"
|
||||
case ""
|
||||
if test -z "$fisher_alias"
|
||||
return 1
|
||||
end
|
||||
|
||||
printf "%s\n" $fisher_alias | sed 's/[=,]/ /g'
|
||||
|
||||
case \*
|
||||
for value in $argv
|
||||
if contains -- $fisher_alias $value
|
||||
continue
|
||||
end
|
||||
|
||||
set -g fisher_alias $fisher_alias $value
|
||||
|
||||
set -l index $fisher_cache/.index
|
||||
|
||||
if not test -e $index
|
||||
continue
|
||||
end
|
||||
|
||||
for alias in (__fisher_alias)
|
||||
switch $alias
|
||||
case install\*
|
||||
__fisher_complete_remote $alias
|
||||
|
||||
case update\* uninstall\*
|
||||
__fisher_complete_cache $alias
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,20 @@
|
||||
function __fisher_cache -d "Calculate path of a name, url or path relative to the cache"
|
||||
while read --prompt="" -l item
|
||||
switch "$item"
|
||||
case file:///\*
|
||||
printf "%s\n" $item
|
||||
|
||||
case \*/\*
|
||||
for file in $fisher_cache/*
|
||||
switch "$item"
|
||||
case (git -C $file ls-remote --get-url | __fisher_validate)
|
||||
printf "%s\n" $file
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
case \*
|
||||
printf "%s\n" $fisher_cache/$item
|
||||
end
|
||||
end
|
||||
end
|
@ -1,17 +1,13 @@
|
||||
function __fish_parse_usage -d "Parse usage help output"
|
||||
switch "$argv[1]"
|
||||
case -h --help
|
||||
printf "Usage\n"
|
||||
printf " __fish_parse_usage [awk_var=value] [--help]\n\n"
|
||||
|
||||
printf "Example\n"
|
||||
printf " set -l IFS \\\t\n"
|
||||
printf " STDIN | __fish_parse_usage | while read -l d l s\n"
|
||||
printf " complete -c <command> -s $s -l $l -d $d\n"
|
||||
printf " end\n"
|
||||
return
|
||||
end
|
||||
# Usage
|
||||
# __fisher_complete [awk_var=value] [--help]
|
||||
#
|
||||
# Example
|
||||
# set -l IFS \t
|
||||
# STDIN | __fisher_complete | while read -l d l s
|
||||
# complete -c <command> -s -l -d
|
||||
# end
|
||||
|
||||
function __fisher_complete -d "Parse usage help output"
|
||||
switch "$argv"
|
||||
case \*OFS=\*
|
||||
case \*
|
@ -0,0 +1,7 @@
|
||||
function __fisher_complete_cache -d "Add auto-complete for cached plugins"
|
||||
set -l IFS ";"
|
||||
fisher_search --index=$fisher_cache/.index --select=cache --name --info \
|
||||
| while read -l name info
|
||||
complete -c fisher -n "__fish_seen_subcommand_from $argv" -a "$name" -d "$info"
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
function __fisher_complete_remote -d "Add auto-complete for remote plugins"
|
||||
set -l IFS ";"
|
||||
fisher_search --index=$fisher_cache/.index --select=remote --name --info \
|
||||
| while read -l name info
|
||||
complete -c fisher -n "__fish_seen_subcommand_from $argv" -a "$name" -d "$info"
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
function __fisher_file -a file -d "Read a fishfile and display its contents"
|
||||
switch "$file"
|
||||
case ""
|
||||
set file $fisher_config/fishfile
|
||||
|
||||
case "-"
|
||||
set file /dev/stdin
|
||||
end
|
||||
|
||||
awk '
|
||||
!/^ *(#.*)*$/ {
|
||||
gsub("#.*", "")
|
||||
|
||||
if (/^ *package .+/) $1 = $2
|
||||
|
||||
if (!duplicates[$1]++) printf("%s\n", $1)
|
||||
}
|
||||
' $file
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
function __fisher_list -d "List plugins in the cache"
|
||||
for file in $fisher_cache/*
|
||||
if test -d $file
|
||||
basename $file
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,3 @@
|
||||
function __fisher_name -d "Generate a pretty name from a plugin path or URL"
|
||||
sed -E 's|.*/(.*)|\1|; s/^(plugin|theme|pkg|omf|fish|fisher)-//'
|
||||
end
|
@ -0,0 +1,43 @@
|
||||
function __fisher_validate -d "Validate a name, url or path"
|
||||
set -l id "[A-Za-z0-9_]+([.-]?[A-Za-z0-9_])*"
|
||||
|
||||
if not set -q fisher_default_host
|
||||
set fisher_default_host https://github.com
|
||||
end
|
||||
|
||||
while read -lp "" item
|
||||
switch "$item"
|
||||
case \*..\* /. /
|
||||
continue
|
||||
end
|
||||
|
||||
if test -e "$item"
|
||||
if test $item = $HOME
|
||||
continue
|
||||
end
|
||||
|
||||
if test -f "$item"
|
||||
set item (dirname $item)
|
||||
end
|
||||
|
||||
if not printf "%s\n" $item | grep "^\/"
|
||||
printf "$PWD/%s/%s" (dirname $item) (basename $item)
|
||||
end | sed -E 's|^/|file:///|;s|[./]*$||'
|
||||
|
||||
else
|
||||
printf "%s\n" $item | sed -En "
|
||||
s#plg?ug?i?n#plugin#
|
||||
s#oh?my?i?f[iy]?h?si?h?#oh-my-fish#
|
||||
s#/\$##
|
||||
s#\.git\$##
|
||||
s#^(https?):*/* *(.*\$)#\1://\2#p
|
||||
s#^(@|(gh[:/])|(github(.com)?[/:]))/?($id)/($id)\$#https://github.com/\5/\7#p
|
||||
s#^(bb[:/])/*($id)/($id)\$#https://bitbucket.org/\2/\4#p
|
||||
s#^(gl[:/])/*($id)/($id)\$#https://gitlab.com/\2/\4#p
|
||||
s#^(omf[:/])/*($id)\$#https://github.com/oh-my-fish/\2#p
|
||||
s#^($id)/($id)\$#$fisher_default_host/\1/\3#p
|
||||
/^file:\/\/\/.*/p
|
||||
/^[a-z]+([._-]?[a-z0-9]+)*\$/p"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,68 +0,0 @@
|
||||
function add(k, v) {
|
||||
if (seen[k v]++) return
|
||||
print k (v == "" ? "" : " "v)
|
||||
}
|
||||
|
||||
function pop() {
|
||||
return (size <= 0) ? "_" : stack[size--]
|
||||
}
|
||||
|
||||
function push(k) {
|
||||
stack[++size] = k
|
||||
}
|
||||
|
||||
function flush() {
|
||||
while (size) {
|
||||
add(pop())
|
||||
}
|
||||
}
|
||||
|
||||
$0 == "" { next }
|
||||
|
||||
done {
|
||||
add("_" , $1$2$3)
|
||||
next
|
||||
}
|
||||
|
||||
$1 == "--" && !$2 {
|
||||
done = 1
|
||||
next
|
||||
}
|
||||
|
||||
$1 !~ /^-|^--/ {
|
||||
add(pop(), $0)
|
||||
next
|
||||
}
|
||||
|
||||
size { flush() }
|
||||
|
||||
$3 {
|
||||
for (i = 4; i <= NF; i++)
|
||||
$3 = $3" "$i
|
||||
}
|
||||
|
||||
$1 == "--" {
|
||||
if ($3 == "")
|
||||
push($2)
|
||||
else
|
||||
add($2, $3)
|
||||
}
|
||||
|
||||
$1 == "-" {
|
||||
if ($2 == "") {
|
||||
print $1
|
||||
next
|
||||
} else {
|
||||
n = split($2, keys, "")
|
||||
}
|
||||
|
||||
if ($3 == "")
|
||||
push(keys[n])
|
||||
else
|
||||
add(keys[n], $3)
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
add(keys[i])
|
||||
}
|
||||
|
||||
END { flush() }
|
@ -1,19 +0,0 @@
|
||||
test "display help help"
|
||||
(fisher help --help | xargs) = "usage: fisher help [<keyword>] [--all] [--guides] [--usage[=<command>]] [--help] -a --all List commands and guides -g --guides List documentation guides -u --usage[=<command>] Display command usage help -h --help Show usage help"
|
||||
end
|
||||
|
||||
test "display install help"
|
||||
(fisher install --help | xargs) = "usage: fisher install [<name or url> ...] [--quiet] [--help] -q --quiet Enable quiet mode -h --help Show usage help"
|
||||
end
|
||||
|
||||
test "display search help"
|
||||
(fisher search --help | xargs) = "usage: fisher search [<name or url>] [--select=<source>] [--field=<field>] [--or|--and] [--quiet] [--help] -s --select=<source> Select all, cache or remote plugins -f --field=<field> Filter by name, url, info, tag or author -a --and Join query with AND operator -o --or Join query with OR operator -q --quiet Enable quiet mode -h --help Show usage help"
|
||||
end
|
||||
|
||||
test "display uninstall help"
|
||||
(fisher uninstall --help | xargs) = "usage: fisher uninstall [<name or url> ...] [--force] [--quiet] [--help] -f --force Delete copy from cache -q --quiet Enable quiet mode -h --help Show usage help"
|
||||
end
|
||||
|
||||
test "display update help"
|
||||
(fisher update --help | xargs) = "usage: fisher update [<name or url> ...] [--me] [--quiet] [--help] -m --me Update Fisherman -q --quiet Enable quiet mode -h --help Show usage help"
|
||||
end
|
Loading…
Reference in New Issue