mirror of https://github.com/jorgebucaran/fisher
Ahoy! Fisherman 0.3.0
* Fix a critical bug in the Makefile that was incorrectly merging any existing user configuration file and the generated Fisherman configuration. Closes #21. * Fix a bug in install and uninstall that was adding plugin names to fishfiles instead of the URL when interacting with custom URLs. Probably closes #23. * Fix a bug in install, update and uninstall that was displaying an incorrect plugin count if there was at least on failure. * Fix bug in `fisher install` that causes install to fail even though it succeeds, due to `wait(1)`'s behavior of returning `1` if there is any output to standard error. Closes #20. * Fix bug in `fisher uninstall` that was removing plugins from the cache by mistake. * Add feature to Makefile to download the index for the first time in order to provide auto-complete before the user can install/update/search, actions which would case the index to be updated. * Add link to Slack [room][wharf] in README. Thanks @simnalamburt. * Add new `$fisher_timeout` configuration variable that lets you specify `curl(1)` `--max-time` option. Without this, `curl` could hang for a long time if you are in a bad connection. * Add `fisher install --link` to allow installing plugins creating a symbolic link to each of the relevant files to be copied during the install process. If you use ***`--link`*** to install a plugin that is a _path to a directory_ or file, a symbolic link to the directory will be created making local testing more convenient as you are not required to update the plugin's repository to test changes within Fisherman. If you are testing using [Fishtape][fishtape] you do not even need to reset the shell session. * Add `fisher --alias[=<command>=<alias>]` to simplify creating new aliases for `fisher` commands. Use `fisher --alias` without arguments to list the current set of aliases. Also add auto-complete for aliases to install, update or uninstall. Note that aliases are **not** persisted this way. To save your aliases use `$fisher_alias` as described in `fisher help config`. Also note that aliases are only auto-complete if you call `fisher --alias`. To auto-complete aliases saved to `$fisher_alias` you can do `fisher --alias (fisher --alias)`. * Add short options for new and old fisher flags: * `--file` → `-f` * `--list` → `-l` * `--alias` → `-a` * Improve help message for failed installs. Closes * Improve `fisher --validate` to automatically correct common misspellings, for example when installing a oh-my-fish package, one often types ohmyifsh. * ☝️ Improve auto-complete performance by extracting the implementation of the different `fisher` flags to `__fisher_*` functions. `completions/fisher.fish` relies heavily in `fisher_search` to query what plugins are available to install/update/uninstall. In this process, numerous calls to `fisher --list` and `fisher --validate`, etc., are made. Now, auto-complete does not have to pay the penalty of entering `fisher`, parsing options, etc. Closes #27. @namandistro * Improve `fisher --help` output and show up until now poorly documented ***`--list`***, ***`--file`***, etc. flags consistently. Also display available commands after `make install` to improve usability. * Improve `fisher install` so that it checks whether the plugin you are trying to install, if it is already in the cache, is a symbolic link or not, and installs it as if the `--link` flag was specified. * Improve `fisher --validate` to retrieve the absolute path to the closest directory of the given items if they are valid local paths. Related #19. * Improve install to not `git clone` local plugins if a regular `path/to/file` is given to `fisher install`. Instead, copy to the cache using `cp(1)` and if `--link` is used, create a symlink. * Improve `fisher --validate` to invalidate items with repeated `.` and `-` and allow items that begin with `/` or `./` to support installing plugins from local paths. Related #19. * Modify `fisher update` default behavior. Now this command updates Fisherman by default. Use of `--self` and `--me` is also **deprecated**. To read from the standard input use a dash `-`. For example: `fisher --list | fisher update -`. Closes #25. * Rename `--cache` to more descriptive ***`--list`***. Thanks @colstrom. * Remove `fisher --cache=base` and make it return the base names of all directories in the path by default. To get the full path use printf `printf "$fisher_cache/%s" (fisher --list)` * Rename undocumented `fisher --translate` flag (again) to `fisher --cache`. This function reads the standard input for a name, URL or local path and calculates the plugin's path relative to the cache. For a name this is simple `$fisher_cache/<name>` for an URL, retrieve the remote URL of every repository until there is a match with the given URL and return the path in the cache of that repository. Finally, if the input is a * Revert #3. The reason `getopts.fish` was in its own file originally is because @bucaran wanted a standalone, dependency free cli parser solution, arguably slightly faster than having Awk read `getopts.awk` for each use. The performance improvement is negligible at best, but `getopts` is also used by every single command and future commands and plugins are very likely to use it as well, so we so we might as well use the slightly faster version.pull/445/head
parent
6b43741f14
commit
aed81667c9
@ -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