From aed81667c95be2e4a929c3b6bcdbd7f7edb56403 Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Fri, 8 Jan 2016 02:44:28 +0900 Subject: [PATCH] Ahoy! Fisherman 0.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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[==]` 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. * :point_up: 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/` 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. --- AUTHORS.md | 1 + CHANGELOG.md | 94 +++++++++++-- Makefile | 16 ++- README.md | 2 +- VERSION | 2 +- completions/fisher.fish | 18 +-- completions/wait.fish | 2 +- config.fish | 2 + functions/__fisher_alias.fish | 35 +++++ functions/__fisher_cache.fish | 20 +++ ...arse_usage.fish => __fisher_complete.fish} | 22 ++-- functions/__fisher_complete_cache.fish | 7 + functions/__fisher_complete_remote.fish | 7 + functions/__fisher_file.fish | 19 +++ functions/__fisher_list.fish | 7 + functions/__fisher_name.fish | 3 + functions/__fisher_validate.fish | 43 ++++++ functions/fisher.fish | 110 ++++------------ functions/fisher_help.fish | 13 +- functions/fisher_install.fish | 124 +++++++++++++----- functions/fisher_search.fish | 16 +-- functions/fisher_uninstall.fish | 47 ++++--- functions/fisher_update.fish | 88 ++++++++----- functions/getopts.fish | 25 +++- functions/wait.fish | 2 +- man/man1/fisher-install.1 | 26 ++-- man/man1/fisher-install.md | 22 ++-- man/man1/fisher-search.1 | 2 +- man/man1/fisher-search.md | 2 +- man/man1/fisher-uninstall.1 | 7 +- man/man1/fisher-uninstall.md | 5 +- man/man1/fisher-update.1 | 17 ++- man/man1/fisher-update.md | 14 +- man/man1/fisher.1 | 64 ++++----- man/man1/fisher.md | 36 ++--- man/man1/getopts.1 | 4 +- man/man1/getopts.md | 4 +- man/man5/fisher-fishfile.5 | 2 +- man/man5/fisher-fishfile.md | 2 +- man/man7/fisher-faq.7 | 20 +-- man/man7/fisher-faq.md | 22 ++-- man/man7/fisher-plugins.7 | 4 +- man/man7/fisher-plugins.md | 4 +- man/man7/fisher.7 | 12 +- man/man7/fisher.md | 12 +- share/getopts.awk | 68 ---------- test/fisher.fish | 6 +- test/help.fish | 9 +- test/install.fish | 2 +- test/other.fish | 19 --- test/update.fish | 1 - test/validate.fish | 50 +++++-- 52 files changed, 700 insertions(+), 461 deletions(-) create mode 100644 functions/__fisher_alias.fish create mode 100644 functions/__fisher_cache.fish rename functions/{__fish_parse_usage.fish => __fisher_complete.fish} (60%) create mode 100644 functions/__fisher_complete_cache.fish create mode 100644 functions/__fisher_complete_remote.fish create mode 100644 functions/__fisher_file.fish create mode 100644 functions/__fisher_list.fish create mode 100644 functions/__fisher_name.fish create mode 100644 functions/__fisher_validate.fish delete mode 100644 share/getopts.awk delete mode 100644 test/other.fish diff --git a/AUTHORS.md b/AUTHORS.md index e430612..f91d525 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,2 +1,3 @@ # Authors * Jorge Bucaran <[j@bucaran.me](mailto:j@bucaran.me)> +* Hyeon Kim <[simnalamburt@gmail.com](mailto:simnalamburt@gmail.com)> diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8504e..6a14c6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,25 +1,92 @@ # Change Log +* [0.3.0](#030) * [0.2.0](#020) * [0.1.0](#010) -## 0.2.0 - 2016-01-05 -* Improved README, added links to screencasts, updated documentation with new changes and fixed other typos and composition errors. +## [0.3.0][v030] - 2016-01-05 -* :warning: Removed `fisher update --cache` in favor of `fisher --cache | fisher update` and `fisher uninstall --all` in favor of `fisher --cache | fisher uninstall`. +> This release contains several breaking changes a few major improvements. The good news is that the API is starting to look more stable and very unlikely to change drastically again in the future. + +### Fixes + +* 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 + +* 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[==]` 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` + +### Improvements + +* Improve help message for failed installs. Closes ##24. @namandistro + +* Improve `fisher --validate` to automatically correct common misspellings, for example when installing a oh-my-fish package, one often types ohmyifsh. + +* :point_up: 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. + +## :warning: Remove / Rename + +* 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 -`. See [Usage of dash in place of a filename](http://unix.stackexchange.com/questions/16357/usage-of-dash-in-place-of-a-filename/16364#16364). 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/` 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 might as well use the slightly faster version. + + +## [0.2.0][v020] - 2016-01-05 + +* Improve README, added links to screencasts, updated documentation with new changes and fixed other typos and composition errors. + +* :warning: Remove `fisher update --cache` in favor of `fisher --list | fisher update` and `fisher uninstall --all` in favor of `fisher --list | fisher uninstall`. * :warning: Fisherman does not move initialization / configuration files following the convention `name`.config.fish to `$fisher_config/functions`, but to `$fisher_config/conf.d` now and evaluates each `*.config.fish` inside at shell start as usual. Closes #13. -* Added `fisher --cache[=base]` option to retrieve contents in `$fisher_cache`, eliminating flaky usage of `find(1)`. Closes #11. +* ~~Add `fisher --cache[=base]` option to retrieve contents in `$fisher_cache`, eliminating flaky usage of `find(1)`~~. Closes #11. * Fisherman now generates information about plugins installed via custom URLs. For the description, a shortened version of the URL is used. For the URL the full URL is used. For tags, the URL is fuzzily checked and tags such as _theme_, _plugin_, _config_ and _omf_ are added. The tag _orphan_ is added by default as well. Finally, the author is generated by retrieving the e-mail or username of the author of the first commit in the plugin's repository. Closes #9 and #14. -* Changed `--path-in-cache` to `--translate.` This function translates an name or supported URL/URL variation into a path inside `$fisher_cache`. This allows you to treat plugins installed via custom URLs almost like regular plugins if they are installed. Closes #8. +* ~~Change `--path-in-cache` to `--translate.` This function translates an name or supported URL/URL variation into a path inside `$fisher_cache`. This allows you to treat plugins installed via custom URLs almost like regular plugins if they are installed. Closes #8.~~ -* Fixed a bug with `mktemp` failing on some systems. Closes #7. Thanks @tobywf. +* Fix a bug where `mktemp` would fail in some systems. Closes #7. Thanks @tobywf. -* Added [CODE_OF_CONDUCT][code_of_conduct]. Closes #6. +* Add [CODE_OF_CONDUCT][code_of_conduct]. Closes #6. * Fisherman can now unload themes within the same shell, without having to restart the session. Closes #5. @@ -29,7 +96,8 @@ * Support dots inside URIs in `fisher --validate`. Closes #2. -* Refactored and improved tests for `install`, `update` and `uninstall`. +* Refactor and improve tests for `install`, `update` and `uninstall`. + ## [0.1.0][v010] - 2016-01-01 @@ -40,6 +108,16 @@ +[v030]: https:// + +[v020]: https://github.com/fisherman/fisherman/commit/54212e1cbce66c7671baa045653efe912dbb4b77 + [v010]: https://github.com/fisherman/fisherman/commit/3386ed052ae4a84338c340d37b98c1742f8a45f6 + [bobthefish-19]: https://github.com/oh-my-fish/theme-bobthefish/pull/19 + [code_of_conduct]: CODE_OF_CONDUCT.md + +[fishtape]: https://github.com/fisherman/fishtape + +[wharf]: http://fisherman-wharf.herokuapp.com/ diff --git a/Makefile b/Makefile index 62ee618..1722551 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,8 @@ MAN5 := $(wildcard $(MAN)/man5/*.md) MAN7 := $(wildcard $(MAN)/man7/*.md) DOCS := $(MAN1:%.md=%.1) $(MAN5:%.md=%.5) $(MAN7:%.md=%.7) +INDEX := $(FISHER_CACHE)/.index + AUTHORS = $(FISHER_HOME)/AUTHORS.md VERSION = `cat $(FISHER_HOME)/VERSION` @@ -22,7 +24,12 @@ TILDEIFY = sed "s|$$HOME|~|" .PHONY: all test flush uninstall release all: $(FISH_CONFIG) $(FISHER_CACHE) $(AUTHORS) $(DOCS) - @$(call MSG,"Reset your shell to apply changes") + @if [ ! -s $(INDEX) ]; then\ + echo "Downloading the index for the first time...";\ + fish -c "fisher_update --index";\ + fi + @$(call MSG,"Reset your shell and type 'fisher ' to use Fisherman.") + @fish -c "fisher -h" | sed -n '5,$$p' test: @fish -c "fishtape test/*.fish" @@ -35,7 +42,7 @@ uninstall: @sed -E '/set (fisher_home|fisher_config) /d;/source \$$fisher_home/d' \ $(FISH_CONFIG) > $(FISH_CONFIG).tmp @mv $(FISH_CONFIG).tmp $(FISH_CONFIG) - @$(call MSG,"Reset your shell to apply changes") + @$(call MSG,"Reset your shell to apply changes.") release: $(FISHER_HOME) @if [ "`git -C $^ status --short --porcelain | xargs`" = "M VERSION" ]; then\ @@ -56,7 +63,7 @@ $(FISH_CONFIG): @echo "set fisher_home $(FISHER_HOME)" | sed "s|/$$||;s|$$HOME|~|" > $@.fisher @echo "set fisher_config $(FISHER_CONFIG)" | sed "s|$$HOME|~|" >> $@.fisher @echo "source \$$fisher_home/config.fish" >> $@.fisher - @awk '!config[$$0]++ || /^$$/' $@.fisher $@ > $@.tmp + @awk 'FNR==NR{ print; a[$$0]; next } !($$0 in a) || /^$$/' $@.fisher $@ > $@.tmp @mv $@.tmp $@ && rm $@.fisher $(FISHER_CACHE): @@ -69,4 +76,5 @@ $(AUTHORS): $(FISHER_HOME) sed -E 's/([^<>]+)<([^<>]*)>/* \1 \<[\2](mailto:\2)\>/' >> $@ %.1 %.5 %.7: %.md - @ronn --manual=fisherman --roff $? 2>&1 | sed 's/^ *roff: *//;s|//|/|g' + @echo "Creating the documentation..." + -@ronn --manual=fisherman --roff $? 1>&2 2> /dev/null diff --git a/README.md b/README.md index 045d1cb..7388239 100644 --- a/README.md +++ b/README.md @@ -52,4 +52,4 @@ See [`fisherman(1)`][fisherman-1] and [`fisherman(7)`][fisherman-7] for usage an [fisherman-7]: man/man7/fisher.md [travis-link]: https://travis-ci.org/fisherman/fisherman [travis-badge]: https://img.shields.io/travis/fisherman/fisherman.svg?style=flat-square -[fisherman-version]: https://img.shields.io/badge/fisherman-v0.2.0-00B9FF.svg?style=flat-square +[fisherman-version]: https://img.shields.io/badge/fisherman-v0.3.0-00B9FF.svg?style=flat-square diff --git a/VERSION b/VERSION index 0ea3a94..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 +0.3.0 diff --git a/completions/fisher.fish b/completions/fisher.fish index 09a4e95..125b24e 100644 --- a/completions/fisher.fish +++ b/completions/fisher.fish @@ -3,12 +3,13 @@ complete -c fisher -n "__fish_seen_subcommand_from search" -a "\t" complete -c fisher -n "__fish_use_subcommand" -s v -l version -d "Show version information" complete -c fisher -n "__fish_use_subcommand" -s h -l help -d "Display help" complete -c fisher -n "__fish_use_subcommand" -s f -l file -d "Read fishfile" +complete -c fisher -n "__fish_use_subcommand" -s a -l alias -d "Define one or more comma-separated command aliases" +complete -c fisher -n "__fish_use_subcommand" -s l -l list -d "List plugins in the cache" -set -l index $fisher_cache/.index set -l IFS ";" for option in commands guides - fisher help --$option=bare | sed -E 's/^ *([^ ]+) *(.*)/\1;\2/' | while read -l func info + fisher_help --$option=bare | sed -E 's/^ *([^ ]+) *(.*)/\1;\2/' | while read -l func info complete -c fisher -n "__fish_seen_subcommand_from help" -a $func -d "$info" @@ -18,20 +19,13 @@ for option in commands guides complete -c fisher -n "__fish_use_subcommand" -a $func -d "$info" - fisher_help --usage=$func | __fish_parse_usage OFS=';' | while read -l 1 2 3 + fisher_help --usage=$func | __fisher_complete OFS=';' | while read -l 1 2 3 complete -c fisher -n "__fish_seen_subcommand_from $func" -s "$3" -l "$2" -d "$1" end end end if test -e $fisher_cache/.index - fisher search --index=$index --select=cache --name --info | while read -l name info - for command in update uninstall - complete -c fisher -n "__fish_seen_subcommand_from $command" -a "$name" -d "$info" - end - end - - fisher search --index=$index --select=remote --name --info | while read -l name info - complete -c fisher -n "__fish_seen_subcommand_from install" -a "$name" -d "$info" - end + __fisher_complete_cache update uninstall + __fisher_complete_remote install end diff --git a/completions/wait.fish b/completions/wait.fish index e09df34..697373c 100644 --- a/completions/wait.fish +++ b/completions/wait.fish @@ -5,6 +5,6 @@ complete -xc wait -d "Run commands and wait with a spin" complete -xc wait -n "not __fish_seen_subcommand_from --spin" -a "\t" set -l IFS \t -wait --help | __fish_parse_usage | while read -l 1 2 3 +wait --help | __fisher_complete | while read -l 1 2 3 complete -c wait -s "$3" -l "$2" -d "$1" end diff --git a/config.fish b/config.fish index e3af53c..cadc112 100644 --- a/config.fish +++ b/config.fish @@ -3,6 +3,8 @@ set fisher_index https://raw.githubusercontent.com/fisherman/fisher-index/master set fisher_error_log $fisher_cache/.debug_log +set fisher_timeout 5 + set fish_function_path {$fisher_config,$fisher_home}/functions $fish_function_path set fish_complete_path {$fisher_config,$fisher_home}/completions $fish_complete_path diff --git a/functions/__fisher_alias.fish b/functions/__fisher_alias.fish new file mode 100644 index 0000000..7112c13 --- /dev/null +++ b/functions/__fisher_alias.fish @@ -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 diff --git a/functions/__fisher_cache.fish b/functions/__fisher_cache.fish new file mode 100644 index 0000000..82636d5 --- /dev/null +++ b/functions/__fisher_cache.fish @@ -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 diff --git a/functions/__fish_parse_usage.fish b/functions/__fisher_complete.fish similarity index 60% rename from functions/__fish_parse_usage.fish rename to functions/__fisher_complete.fish index cce00dd..cac6ab0 100644 --- a/functions/__fish_parse_usage.fish +++ b/functions/__fisher_complete.fish @@ -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 -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 -s -l -d +# end +function __fisher_complete -d "Parse usage help output" switch "$argv" case \*OFS=\* case \* diff --git a/functions/__fisher_complete_cache.fish b/functions/__fisher_complete_cache.fish new file mode 100644 index 0000000..d20b348 --- /dev/null +++ b/functions/__fisher_complete_cache.fish @@ -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 diff --git a/functions/__fisher_complete_remote.fish b/functions/__fisher_complete_remote.fish new file mode 100644 index 0000000..8dee3a3 --- /dev/null +++ b/functions/__fisher_complete_remote.fish @@ -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 diff --git a/functions/__fisher_file.fish b/functions/__fisher_file.fish new file mode 100644 index 0000000..06a9da8 --- /dev/null +++ b/functions/__fisher_file.fish @@ -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 diff --git a/functions/__fisher_list.fish b/functions/__fisher_list.fish new file mode 100644 index 0000000..3f985d0 --- /dev/null +++ b/functions/__fisher_list.fish @@ -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 diff --git a/functions/__fisher_name.fish b/functions/__fisher_name.fish new file mode 100644 index 0000000..fc9668e --- /dev/null +++ b/functions/__fisher_name.fish @@ -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 diff --git a/functions/__fisher_validate.fish b/functions/__fisher_validate.fish new file mode 100644 index 0000000..fbdc750 --- /dev/null +++ b/functions/__fisher_validate.fish @@ -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 diff --git a/functions/fisher.fish b/functions/fisher.fish index 3b6e66a..1640b6a 100644 --- a/functions/fisher.fish +++ b/functions/fisher.fish @@ -1,4 +1,4 @@ -function fisher -d "Fish plugin manager" +function fisher -d "Fish Shell Plugin Manager" if not set -q argv[1] fisher --help return 1 @@ -7,6 +7,7 @@ function fisher -d "Fish plugin manager" set -l option set -l value set -l quiet -E . + set -l alias getopts $argv | while read -l 1 2 switch "$1" @@ -15,17 +16,19 @@ function fisher -d "Fish plugin manager" set value $2 break + case a alias + set option alias + set alias $alias $2 + case h help set option help set value $value $2 - case cache - set option cache - set value $2 + case l list + set option list - case translate - set option translate - set value $2 + case c cache + set option cache case f file set option file @@ -33,7 +36,9 @@ function fisher -d "Fish plugin manager" case V validate set option validate - set value $2 + + case name + set option translate case v version set option version @@ -42,7 +47,7 @@ function fisher -d "Fish plugin manager" set quiet -q . case \* - printf "fisher: '%s' is not a valid option\n" $1 >& 2 + printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 fisher --help >& 2 return 1 end @@ -50,7 +55,7 @@ function fisher -d "Fish plugin manager" switch "$option" case command - printf "%s\n" $fisher_alias | sed 's/[=,]/ /g' | while read -la alias + __fisher_alias | while read -la alias if set -q alias[2] switch "$value" case $alias[2..-1] @@ -73,81 +78,22 @@ function fisher -d "Fish plugin manager" end case validate - if not test -z "$value" - printf "%s\n" $value | fisher --validate | grep $quiet - return - end + __fisher_validate | grep $quiet - if not set -q fisher_default_host - set fisher_default_host https://github.com - end - - set -l id "[A-Za-z0-9_.-]" - - sed -En " - s#/\$## - s#\.git\$## - s#^(https?):*/* *(.*\$)#\1://\2#p - s#^(@|(gh[:/])|(github(.com)?[/:]))/?($id+)/($id+)\$#https://github.com/\5/\6#p - s#^(bb[:/])/*($id+)/($id+)\$#https://bitbucket.org/\2/\3#p - s#^(gl[:/])/*($id+)/($id+)\$#https://gitlab.com/\2/\3#p - s#^(omf[:/])/*($id+)\$#https://github.com/oh-my-fish/\2#p - s#^($id+)/($id+)\$#$fisher_default_host/\1/\2#p - /^file:\/\/\/.*/p - /^[a-z]+([._-]?[a-z0-9]+)*\$/p - " | grep $quiet + case list + __fisher_list case cache - for file in $fisher_cache/* - if test -d $file - switch "$value" - case base - basename $file - - case \* - printf "%s\n" $file - end - end - end - - case translate - while read --prompt="" -l item - switch "$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 + __fisher_cache case file - switch "$value" - case "-" - set value /dev/stdin - case "" - set value $fisher_config/fishfile - end + __fisher_file "$value" - awk ' - !/^ *(#.*)*$/ { - gsub("#.*", "") + case alias + __fisher_alias $alias - if (/^ *package .+/) { - $1 = $2 - } - - if (!k[$1]++) { - printf("%s\n", $1) - } - } - ' $value + case name + __fisher_name case version sed 's/^/fisher version /;q' $fisher_home/VERSION @@ -157,18 +103,20 @@ function fisher -d "Fish plugin manager" set value commands end - printf "usage: fisher [] [--version] [--help]\n\n" + printf "usage: fisher [--version] [--help] [--list] [--quiet]\n" + printf " [-a =alias[,...]] [-f ]\n" + printf " []\n\n" switch commands case $value - printf "Available Fisherman commands:\n" + printf "Available Commands:\n" fisher_help --commands=bare echo end switch guides case $value - printf "Available Fisherman guides:\n" + printf "Other Documentation:\n" fisher_help --guides=bare echo end diff --git a/functions/fisher_help.fish b/functions/fisher_help.fish index dbd4c31..8467419 100644 --- a/functions/fisher_help.fish +++ b/functions/fisher_help.fish @@ -30,17 +30,16 @@ function fisher_help -d "Display Help Information" set value $value $2 case h help - printf "usage: fisher help [] [--all] [--guides]\n" - printf " [--usage[=]] [--help]\n\n" + printf "usage: fisher help [] [--all] [--guides] [--help]\n\n" - printf " -a --all List commands and guides \n" - printf " -g --guides List documentation guides \n" - printf " -u --usage[=] Display command usage help \n" - printf " -h --help Show usage help \n" + printf " -a --all List available documentation \n" + printf " -g --guides List available guides \n" + printf " -u --usage[=] Display command usage help \n" + printf " -h --help Show usage help \n" return case \* - printf "fisher: '%s' is not a valid option\n" $1 >& 2 + printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 fisher_help --help >& 2 return 1 end diff --git a/functions/fisher_install.fish b/functions/fisher_install.fish index 43f1564..2ee8328 100644 --- a/functions/fisher_install.fish +++ b/functions/fisher_install.fish @@ -1,5 +1,6 @@ -function fisher_install -d "Enable / Install Plugins" +function fisher_install -d "Enable / Install one or more plugins" set -l items + set -l option set -l error /dev/stderr getopts $argv | while read -l 1 2 @@ -7,41 +8,45 @@ function fisher_install -d "Enable / Install Plugins" case _ set items $items $2 + case s l link + set option link + case q quiet set error /dev/null case h help - printf "usage: fisher install [ ...] [--quiet] [--help]\n\n" + printf "usage: fisher install [ ...] [--link] [--quiet]\n" + printf " [--help]\n\n" + printf " -s --link Install as symbolic links\n" printf " -q --quiet Enable quiet mode\n" printf " -h --help Show usage help\n" return case \* - printf "fisher: '%s' is not a valid option\n" $1 >& 2 + printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 fisher_install --help >& 2 return 1 end end set -l count 0 - set -l total (count $items) + set -l index 1 set -l elapsed (date +%s) + set -l total (count $items) if set -q items[1] printf "%s\n" $items else - fisher --file=- + __fisher_file - - end | fisher --validate | while read -l item + end | __fisher_validate | while read -l item switch "$item" case \*/\* printf "%s %s\n" $item ( if not fisher_search --url=$item --name - printf "%s" $item | sed -E ' - s/.*\/(.*)/\1/ - s/^(plugin|theme|pkg|omf|fish|fisher)-//' + printf "%s\n" $item | __fisher_name end) case \* @@ -52,7 +57,7 @@ function fisher_install -d "Enable / Install Plugins" printf "%s %s\n" (git -C $fisher_cache/$item ls-remote --get-url) $item else - printf "fisher: '%s' not found\n" $item > $error + printf "fisher: '%s' path not found\n" $item > $error end end @@ -65,7 +70,9 @@ function fisher_install -d "Enable / Install Plugins" printf ">> %s\n" $name > $error case \* - printf "(%s of %s) >> %s\n" (math 1 + $count) $total $name > $error + printf "(%s of %s) >> %s\n" $index $total $name > $error + + set index (math $index + 1) end mkdir -p $fisher_config/{cache,functions,completions,conf.d,man} @@ -73,14 +80,36 @@ function fisher_install -d "Enable / Install Plugins" set -l path $fisher_cache/$name if not test -e $path - if not wait --spin=pipe --log=$fisher_error_log " - git clone --quiet --depth 1 $url $path" + switch "$url" + case file:///\* + set url (printf "%s\n" $url | sed 's|file://||') - printf "fisher: Repository not found: '%s'\n" $url > $error - continue + if test "$option" = link + ln -sF $url $path + else + cp -rf $url $path + end + + case \* + if not wait --spin=pipe --log=$fisher_error_log " + git clone --quiet --depth 1 $url $path" + + printf "fisher: Repository not found: '%s'\n" $url > $error + + switch "$url" + case \*oh-my-fish\* + printf "Did you miss a 'plugin-' or 'theme-' prefix?\n" > $error + end + + continue + end end end + if test -L $path + set option link + end + set -l bundle $path/fishfile if test -e $path/bundle @@ -90,7 +119,7 @@ function fisher_install -d "Enable / Install Plugins" if test -e $bundle printf "Resolving dependencies in %s\n" $name/(basename $bundle) > $error - set -l deps (fisher --file=$bundle \ + set -l deps (__fisher_file $bundle \ | fisher_install ^&1 \ | sed -En 's/([0-9]+) plugin\/s.*/\1/p') @@ -99,20 +128,20 @@ function fisher_install -d "Enable / Install Plugins" if test -s $path/Makefile -o -s $path/makefile pushd $path - if not make > /dev/null ^ $error + if not make > /dev/null ^ $fisher_error_log + cat $fisher_error_log popd - printf "fisher: Can't make '%s'\n" $name > $error continue end popd end if test -e $path/fish_prompt.fish -o -e $path/fish_right_prompt.fish - rm -f $fisher_config/functions/{fish_prompt,fish_right_prompt}.fish + rm -f $fisher_config/functions/fish_{,right_}prompt.fish functions -e fish_{,right_}prompt end - for file in $path/{*,functions{/*,/**/*}}.fish + for file in $path/{*,functions{/*,/**}}.fish set -l base (basename $file) switch $base @@ -125,45 +154,70 @@ function fisher_install -d "Enable / Install Plugins" switch $base case \*\?.config.fish - cp -f $file $fisher_config/conf.d/$base + if test "$option" = link + ln -sF $file $fisher_config/conf.d/$base + else + cp -f $file $fisher_config/conf.d/$base + end case \* - cp -f $file $fisher_config/functions/$base + if test "$option" = link + ln -sF $file $fisher_config/functions/$base + else + cp -f $file $fisher_config/functions/$base + end end end - cp -f $path/completions/*.fish $fisher_config/completions/ ^ /dev/null + if test "$option" = link + for file in $path/completions/*.fish + ln -sF $file $fisher_config/completions/(basename $file) + end + else + cp -f $path/completions/*.fish $fisher_config/completions/ ^ /dev/null + end for n in (seq 9) if test -d $path/man/man$n mkdir -p $fisher_config/man/man$n end - cp -f $path/man/man$n/*.$n $fisher_config/man/man$n/ ^ /dev/null + + for file in $path/man/man$n/*.$n + if test "$option" = link + ln -sF $file $fisher_config/man/man$n + else + cp -f $file $fisher_config/man/man$n + end + end end set count (math $count + 1) set -l file $fisher_config/fishfile + touch $file + + set -l item $name + + if fisher_search --name=$name --and --tag=orphan --quiet + set item $url + end + if test -s $file - if fisher --file=$file | grep -Eq "^$name\$|^$url\$" + if __fisher_file $file | grep -Eq "^$item\$" continue end end - touch $file - - if not fisher_search --name=$name --field=name --quiet - set name $url - end - - printf "%s\n" "$name" >> $file + printf "%s\n" "$item" >> $file end - printf "%d plugin/s installed (%0.fs)\n" (math $count) ( - math (date +%s) - $elapsed) > $error + set elapsed (math (date +%s) - $elapsed) - if not test $count -gt 0 + if test "$count" = 0 + printf "No plugins were installed.\n" > $error return 1 end + + printf "Aye! %d plugin/s installed in %0.fs\n" $count $elapsed > $error end diff --git a/functions/fisher_search.fish b/functions/fisher_search.fish index 52379c5..10f02f4 100644 --- a/functions/fisher_search.fish +++ b/functions/fisher_search.fish @@ -15,7 +15,7 @@ function fisher_search -d "Search Fisherman Index" case \*/\* set 1 url - set -l url (fisher --validate=$2) + set -l url (printf "%s\n" $2 | __fisher_validate) if not test -z "$url" set 2 $url end @@ -75,8 +75,8 @@ function fisher_search -d "Search Fisherman Index" set quiet 1 case h help - printf "usage: fisher search [] [--select=] [--field=]\n" - printf " [--or|--and] [--quiet] [--help]\n\n" + printf "usage: fisher search [] [--select=] [--quiet]\n" + printf " [--or|--and] [--field=] [--help]\n\n" printf " -s --select= Select all, cache or remote plugins \n" printf " -f --field= Filter by name, url, info, tag or author \n" @@ -87,7 +87,7 @@ function fisher_search -d "Search Fisherman Index" return case \* - printf "fisher: '%s' is not a valid option\n" $1 >& 2 + printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 fisher_search --help >& 2 return 1 end @@ -117,7 +117,7 @@ function fisher_search -d "Search Fisherman Index" return 1 end - set -l cache (fisher --cache=base) + set -l cache (__fisher_list) awk -v FS='\n' -v RS='' -v cache_items="$cache" ' BEGIN { @@ -159,7 +159,7 @@ function fisher_search -d "Search Fisherman Index" set -l tags orphan for tag in theme plugin oh-my-fish config - if printf "%s" "$url" | grep -q $tag + if printf "%s\n" "$url" | grep -q $tag switch "$tag" case oh-my-fish set tag omf @@ -174,10 +174,10 @@ function fisher_search -d "Search Fisherman Index" cat $index case remote - fisher_search --index=$index --and --name!=(fisher --cache=base) + fisher_search --index=$index --and --name!=(__fisher_list) case cache - fisher --cache=base | read -laz cache + __fisher_list | read -laz cache if test -z "$cache" return 1 diff --git a/functions/fisher_uninstall.fish b/functions/fisher_uninstall.fish index e001557..9e2ef51 100644 --- a/functions/fisher_uninstall.fish +++ b/functions/fisher_uninstall.fish @@ -26,29 +26,35 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" return case \* - printf "fisher: '%s' is not a valid option\n" $1 >& 2 + printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 fisher_uninstall --help >& 2 return 1 end end set -l count 0 - set -l duration (date +%s) + set -l index 1 set -l total (count $items) + set -l elapsed (date +%s) if set -q items[1] printf "%s\n" $items else - fisher --file=- - - end | fisher --validate | fisher --translate | while read -l path + __fisher_file - + end | __fisher_validate | __fisher_cache | while read -l path if not test -d "$path" - printf "fisher: '%s' not found\n" $path > $error - continue + switch "$path" + case file:///\* + set path (printf "%s\n" $path | sed 's|file://||') + + case \* + printf "fisher: '%s' path not found\n" $path > $error + continue + end end - set -l name (basename $path) + set -l name (printf "%s\n" $path | __fisher_name) printf "Uninstalling " > $error @@ -57,10 +63,10 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" printf ">> %s\n" $name > $error case \* - printf "(%s of %s) >> %s\n" (math 1 + $count) $total $name > $error - end + printf "(%s of %s) >> %s\n" (math 1 + $index) $total $name > $error - set count (math $count + 1) + set index (math $index + 1) + end for file in $path/{*,functions{/*,/**/*}}.fish set -l base (basename $file) @@ -77,7 +83,7 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" set base $name.(basename $base .fish).config.fish end - rm -f $file $fisher_config/{functions,conf.d}/$base + rm -f $fisher_config/{functions,conf.d}/$base end for file in $path/completions/*.fish @@ -92,16 +98,18 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" end end - git -C $path ls-remote --get-url ^ /dev/null | fisher --validate | read -l url + git -C $path ls-remote --get-url ^ /dev/null | __fisher_validate | read -l url switch force case $option rm -rf $path end + set count (math $count + 1) + set -l file $fisher_config/fishfile - if not fisher --file=$file | grep -Eq "^$name\$|^$url\$" + if not __fisher_file $file | grep -Eq "^$name\$|^$url\$" continue end @@ -110,14 +118,19 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" if not sed -E '/^ *'(printf "%s|%s" $name $url | sed 's|/|\\\/|g' )'([ #].*)*$/d' < $file > $tmp rm -f $tmp - printf "fisher: can't delete '%s' from %s\n" $name $file > $error + printf "fisher: Could not remove '%s' from %s\n" $name $file > $error return 1 end mv -f $tmp $file end - printf "%d plugin/s uninstalled (%0.fs)\n" $count (math (date +%s) - $duration) > $error + set elapsed (math (date +%s) - $elapsed) - test $count -gt 0 + if test $count = 0 + printf "No plugins were uninstalled.\n" > $error + return 1 + end + + printf "Aye! %d plugin/s uninstalled in %0.fs\n" > $error $count $elapsed end diff --git a/functions/fisher_update.fish b/functions/fisher_update.fish index 6ace259..0911f55 100644 --- a/functions/fisher_update.fish +++ b/functions/fisher_update.fish @@ -1,12 +1,13 @@ function fisher_update -d "Fisherman Update Manager" - set -l option set -l path set -l items + set -l option self set -l error /dev/stderr getopts $argv | while read -l 1 2 switch "$1" - case _ + case - _ + set option set items $items $2 case index @@ -16,31 +17,27 @@ function fisher_update -d "Fisherman Update Manager" set option path set path $2 - case m me self fisher{,man} - set option $option me - case q quiet - if test -z "$2" - set 2 /dev/null - end - set error $2 case help h - printf "usage: fisher update [ ...] [--me] [--quiet] [--help]\n\n" + printf "usage: fisher update [ ...] [--quiet] [--help]\n\n" - printf " -m --me Update Fisherman\n" printf " -q --quiet Enable quiet mode\n" printf " -h --help Show usage help \n" return case \* - printf "fisher: '%s' is not a valid option\n" $1 >& 2 + printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 fisher_update --help >& 2 return 1 end end + if test -z "$error" + set error /dev/null + end + switch "$option" case path if not test -d $path @@ -49,47 +46,64 @@ function fisher_update -d "Fisherman Update Manager" end wait --spin=pipe --log=$fisher_error_log " + git -C $path checkout --quiet master ^/dev/null - git -C $path pull --quiet --rebase origin master" + git -C $path pull --quiet --rebase origin master + + " case index mkdir -p $fisher_cache set -l index $fisher_cache/.index.tmp - if curl -s $fisher_index > $index + if wait --spin=pipe --log=$fisher_error_log " + curl --max-time $fisher_timeout -sS $fisher_index > $index + " mv -f $index $fisher_cache/.index + else + printf "fisher: Connection timeout. Try again.\n" > $error end rm -f $index - case me - set -l elap (date +%s) + case self + set -l elapsed (date +%s) printf "Updating >> Fisherman\n" > $error if not fisher_update --path=$fisher_home --quiet=$error + + printf "fisher: Could not update Fisherman.\n" > $error + sed -E 's/.*(error:.*)/\1/' $fisher_error_log > $error + return 1 end - printf "Done without errors (%0.fs)\n" (math (date +%s) - $elap) > $error + printf "Done without errors (%0.fs)\n" ( + math (date +%s) - $elapsed) > $error case \* - set -l elap (date +%s) set -l count 0 + set -l index 1 set -l total (count $items) + set -l elapsed (date +%s) if set -q items[1] printf "%s\n" $items else - fisher --file=- - end | fisher --validate | fisher --translate | while read -l path + __fisher_file - + end | __fisher_validate | __fisher_cache | while read -l path if not test -d "$path" - printf "fisher: '%s' not found\n" $path > $error - continue + switch "$path" + case file:///\* + case \* + printf "fisher: '%s' path not found\n" $path > $error + continue + end end - set -l name (basename $path) + set -l name (printf "%s\n" $path | __fisher_name) printf "Updating " > $error @@ -98,21 +112,35 @@ function fisher_update -d "Fisherman Update Manager" printf ">> %s\n" $name > $error case \* - printf "(%s of %s) >> %s\n" (math 1 + $count) $total $name > $error + printf "(%s of %s) >> %s\n" $index $total $name > $error + + set index (math $index + 1) end - if not fisher_update --path=$path --quiet=$error - sed -nE 's/.*(error|fatal): (.*)/error: \2/p' $fisher_error_log > $error - continue + switch "$path" + case file:///\* + case \* + if not test -L $path + if not fisher_update --path=$path --quiet=$error + sed -nE 's/.*(error|fatal): (.*)/error: \2/p + ' $fisher_error_log > $error + continue + end + end end - fisher install $name --quiet + fisher install --quiet -- (printf "%s\n" $name | __fisher_name) set count (math $count + 1) end - printf "%d plugin/s updated (%0.fs)\n" $count (math (date +%s) - $elap) > $error + set elapsed (math (date +%s) - $elapsed) - test $count -gt 0 + if test $count = 0 + printf "No plugins were updated.\n" > $error + return 1 + end + + printf "Aye! %d plugin/s updated in %0.fs\n" > $error $count $elapsed end end diff --git a/functions/getopts.fish b/functions/getopts.fish index 7a1a57a..aafa679 100644 --- a/functions/getopts.fish +++ b/functions/getopts.fish @@ -4,7 +4,26 @@ function getopts -d "Parse CLI options" end printf "%s\n" $argv | sed -E ' - s/^-([A-Za-z]+)/- \1 / - s/^--([A-Za-z0-9_-]+)(!?)=?(.*)/-- \1 \3 \2 /' | \ - awk -f $fisher_home/share/getopts.awk + s/^-([A-Za-z]+)/- \1 /; s/^--([A-Za-z0-9_-]+)(!?)=?(.*)/-- \1 \3 \2 /' | awk ' + + function out(k,v) { if (!seen[k v]++) print k (v == "" ? "" : " "v) } + function pop() { return len <= 0 ? "_" : opt[len--] } + + !/^ *$/ { + if (done) out("_" , $1$2$3) + else if ($1 == "--" && !$2) done = 1 + else if ($1 !~ /^-|^--/ ) out(pop(), $0) + else { + while (len) out(pop()) + if ($3) for (i = 4; i <= NF; i++) $3 = $3" "$i + if ($1 == "--") if ($3 == "") opt[++len] = $2; else out($2, $3) + if ($1 == "-") { + if ($2 == "") { print $1; next } else n = split($2, keys, "") + if ($3 == "") opt[++len] = keys[n]; else out(keys[n], $3) + for (i = 1; i < n; i++) out(keys[i]) + } + } + } + END { while (len) out(pop()) } + ' end diff --git a/functions/wait.fish b/functions/wait.fish index ed7e95f..265fa14 100644 --- a/functions/wait.fish +++ b/functions/wait.fish @@ -101,7 +101,7 @@ function wait -d "Run commands and wait with a spin" while true if status --is-interactive for i in $spinners - printf "$format" | awk -v t=$time -v i=(printf "%s" $i | sed 's/=/\\\=/') ' + printf "$format" | awk -v t=$time -v i=(printf "%s\n" $i | sed 's/=/\\\=/') ' { system("tput civis") gsub("@", i) diff --git a/man/man1/fisher-install.1 b/man/man1/fisher-install.1 index 5dbeed1..f3c74c9 100644 --- a/man/man1/fisher-install.1 +++ b/man/man1/fisher-install.1 @@ -7,7 +7,7 @@ \fBfisher\-install\fR \- Enable / Install plugins . .SH "SYNOPSIS" -fisher \fBinstall\fR [\fIname\fR or \fIurl\fR \.\.\.] [\fB\-\-quiet\fR] [\fB\-\-help\fR] +fisher \fBinstall\fR [\fIname\fR, \fIurl\fR or \fIpath\fR \.\.\.] [\fB\-\-link\fR] [\fB\-\-quiet\fR] [\fB\-\-help\fR] . .SH "USAGE" fisher \fBinstall\fR \fIplugin\fR \.\.\. @@ -16,12 +16,15 @@ fisher \fBinstall\fR \fIplugin\fR \.\.\. fisher \fBinstall\fR \fIowner/repo\fR \.\.\. . .br +fisher \fBinstall\fR \fIpath\fR \.\.\. +. +.br . .SH "DESCRIPTION" Install one or \fImore\fR plugins by \fIname\fR, searching \fB$fisher_index\fR or by \fIurl\fR\. If no arguments are given, read the standard input\. . .P -If the domain or host is not provided, Fisherman will use any value in \fB$fisher_default_host\fR\. The default is \fBhttps://github\.com\fR\. +If the domain or host is not provided, Fisherman will use any value in \fB$fisher_default_host\fR\. The default value is \fBhttps://github\.com\fR\. . .P In addition, all of the following variations are accepted: @@ -33,7 +36,7 @@ In addition, all of the following variations are accepted: . .IP "\(bu" 4 -\fBgh:\fRowner/repo \fB\->\fR https://github\.com/owner/repo +\fBgh\fRowner/repo \fB\->\fR https://github\.com/owner/repo . .br @@ -44,19 +47,19 @@ In addition, all of the following variations are accepted: Shortcuts for other common Git repository hosting services are also available: . .IP "\(bu" 4 -\fBbb:\fR/owner/repo \fB\->\fR https://bitbucket\.org/owner/repo +\fBbb\fR/owner/repo \fB\->\fR https://bitbucket\.org/owner/repo . .br . .IP "\(bu" 4 -\fBgl:\fR/owner/repo \fB\->\fR https://gitlab\.com/owner/repo +\fBgl\fR/owner/repo \fB\->\fR https://gitlab\.com/owner/repo . .br . .IP "\(bu" 4 -\fBomf:\fR/owner/repo \fB\->\fR https://github\.com/oh\-my\-fish/repo +\fBomf\fR/owner/repo \fB\->\fR https://github\.com/oh\-my\-fish/repo . .br @@ -64,7 +67,10 @@ Shortcuts for other common Git repository hosting services are also available: .IP "" 0 . .P -If a copy of the plugin already exists in \fB$fisher_cache\fR, the relevant files will be copied to \fB$fisher_config\fR/functions, otherwise the plugin repository is first downloaded\. If you wish to update a plugin, use \fBfisher update\fR \fIplugin\fR instead\. +If a copy of the plugin already exists in \fB$fisher_cache\fR, only the relevant files are copied to \fB$fisher_config\fR/functions, otherwise the plugin repository is first downloaded\. If you wish to update a plugin, use \fBfisher update\fR \fIplugin\fR instead\. +. +.P +If a local path is given, copy the directory to the cache\. . .P If the plugin declares dependencies, these will be installed as well\. If any dependencies are already installed they will not be updated in order to prevent version issues\. See \fBfisher help fishfile\fR#{\fBPlugins\fR}\. @@ -75,6 +81,10 @@ If a plugin includes either a fish_prompt\.fish or fish_right_prompt\.fish, both .SH "OPTIONS" . .TP +\fB\-s\fR \fB\-\-link\fR +Create a symbolic link to the plugin repository in the cache or to the original source directory if a local path is given\. +. +.TP \fB\-q\fR \fB\-\-quiet\fR Enable quiet mode\. . @@ -144,7 +154,7 @@ Here is the \fIplugin\fR tree inside the cache: .br . .P -And thisi is how the files are copied from \fB$fisher_cache\fR/plugin to \fB$fisher_config\fR: +And this is how the files are copied from \fB$fisher_cache\fR/plugin to \fB$fisher_config\fR: . .IP "1." 4 \fIplugin\fR\.fish \fB\->\fR $fisher_config/functions diff --git a/man/man1/fisher-install.md b/man/man1/fisher-install.md index c797452..64449a4 100644 --- a/man/man1/fisher-install.md +++ b/man/man1/fisher-install.md @@ -3,31 +3,34 @@ fisher-install(1) -- Enable / Install plugins ## SYNOPSIS -fisher `install` [*name* or *url* ...] [`--quiet`] [`--help`] +fisher `install` [*name*, *url* or *path* ...] [`--link`] [`--quiet`] [`--help`] ## USAGE fisher `install` *plugin* ...
fisher `install` *owner/repo* ...
+fisher `install` *path* ...
## DESCRIPTION Install one or *more* plugins by *name*, searching `$fisher_index` or by *url*. If no arguments are given, read the standard input. -If the domain or host is not provided, Fisherman will use any value in `$fisher_default_host`. The default is `https://github.com`. +If the domain or host is not provided, Fisherman will use any value in `$fisher_default_host`. The default value is `https://github.com`. In addition, all of the following variations are accepted: * `github`/owner/repo `->` https://github.com/owner/repo
-* `gh:`owner/repo `->` https://github.com/owner/repo
+* `gh`owner/repo `->` https://github.com/owner/repo
Shortcuts for other common Git repository hosting services are also available: -* `bb:`/owner/repo `->` https://bitbucket.org/owner/repo
-* `gl:`/owner/repo `->` https://gitlab.com/owner/repo
-* `omf:`/owner/repo `->` https://github.com/oh-my-fish/repo
+* `bb`/owner/repo `->` https://bitbucket.org/owner/repo
+* `gl`/owner/repo `->` https://gitlab.com/owner/repo
+* `omf`/owner/repo `->` https://github.com/oh-my-fish/repo
-If a copy of the plugin already exists in `$fisher_cache`, the relevant files will be copied to `$fisher_config`/functions, otherwise the plugin repository is first downloaded. If you wish to update a plugin, use `fisher update` *plugin* instead. +If a copy of the plugin already exists in `$fisher_cache`, only the relevant files are copied to `$fisher_config`/functions, otherwise the plugin repository is first downloaded. If you wish to update a plugin, use `fisher update` *plugin* instead. + +If a local path is given, copy the directory to the cache. If the plugin declares dependencies, these will be installed as well. If any dependencies are already installed they will not be updated in order to prevent version issues. See `fisher help fishfile`#{`Plugins`}. @@ -35,6 +38,9 @@ If a plugin includes either a fish_prompt.fish or fish_right_prompt.fish, both f ## OPTIONS +* `-s` `--link`: + Create a symbolic link to the plugin repository in the cache or to the original source directory if a local path is given. + * `-q` `--quiet`: Enable quiet mode. @@ -68,7 +74,7 @@ Here is the *plugin* tree inside the cache: |-- *plugin*.1
-And thisi is how the files are copied from `$fisher_cache`/plugin to `$fisher_config`: +And this is how the files are copied from `$fisher_cache`/plugin to `$fisher_config`: 1. *plugin*.fish `->` $fisher_config/functions 2. functions/plugin_helper.fish `->` $fisher_config/functions diff --git a/man/man1/fisher-search.1 b/man/man1/fisher-search.1 index 1ff3531..c641056 100644 --- a/man/man1/fisher-search.1 +++ b/man/man1/fisher-search.1 @@ -83,7 +83,7 @@ Filter the result set by \fIfield\fR=\fImatch\fR, where \fIfield\fR can be one o . .TP \-\-\fIfield\fR[~\fB/\fR\fIregex\fR\fB/\fR] -Essentially the same as \-\-\fIfield\fR=\fImatch\fR, but with Regular Expression support\. \-\-\fIfield\fR~\fB/\fR\fIregex\fR\fB/\fR filters the result set using the given \fB/\fR\fIregex\fR\fB/\fR\. For example, \-\-name=\fB/\fR^\fImatch\fR$\fB/\fR is the same as \-\-\fIfield\fR=\fImatch\fR and \-\-url~\fB/\fRoh\-my\-fish\fB/\fR selects only Oh My Fish! plugins\. Use \fB!~\fR to negate the query\. +Essentially the same as \-\-\fIfield\fR=\fImatch\fR, but with Regular Expression support\. \-\-\fIfield\fR~\fB/\fR\fIregex\fR\fB/\fR filters the result set using the given \fB/\fR\fIregex\fR\fB/\fR\. For example, \-\-name=\fB/\fR^\fImatch\fR$\fB/\fR is the same as \-\-\fIfield\fR=\fImatch\fR and \-\-url~\fB/\fRoh\-my\-fish\fB/\fR selects only oh-my-fish plugins\. Use \fB!~\fR to negate the query\. . .TP \fB\-a\fR \fB\-\-and\fR diff --git a/man/man1/fisher-search.md b/man/man1/fisher-search.md index c384af6..d792f80 100644 --- a/man/man1/fisher-search.md +++ b/man/man1/fisher-search.md @@ -48,7 +48,7 @@ See #{`Output`} for more information. Filter the result set by *field*=*match*, where *field* can be one or more of `name`, `url`, `info`, `tag` or `author`. If *match* is not given, this is equivalent to `--select`=*field*. Use `!=` to negate the query. * --*field*[~`/`*regex*`/`]: - Essentially the same as --*field*=*match*, but with Regular Expression support. --*field*~`/`*regex*`/` filters the result set using the given `/`*regex*`/`. For example, --name=`/`^*match*$`/` is the same as --*field*=*match* and --url~`/`oh-my-fish`/` selects only Oh My Fish! plugins. Use `!~` to negate the query. + Essentially the same as --*field*=*match*, but with Regular Expression support. --*field*~`/`*regex*`/` filters the result set using the given `/`*regex*`/`. For example, --name=`/`^*match*$`/` is the same as --*field*=*match* and --url~`/`oh-my-fish`/` selects only oh-my-fish plugins. Use `!~` to negate the query. * `-a` `--and`: Join query with a logical AND operator. diff --git a/man/man1/fisher-uninstall.1 b/man/man1/fisher-uninstall.1 index 56979eb..ca6e1fe 100644 --- a/man/man1/fisher-uninstall.1 +++ b/man/man1/fisher-uninstall.1 @@ -7,7 +7,7 @@ \fBfisher\-uninstall\fR \- Disable / Uninstall Plugins . .SH "SYNOPSIS" -fisher \fBuninstall\fR [\fIname\fR or \fIurl\fR \.\.\.] +fisher \fBuninstall\fR [\fIname\fR, \fIurl\fR or \fIpath\fR \.\.\.] . .br fisher \fBuninstall\fR [\fB\-\-force\fR] [\fB\-\-quiet\fR] [\fB\-\-help\fR] @@ -21,6 +21,9 @@ fisher \fBuninstall\fR \fIplugin\fR \.\.\. fisher \fBuninstall\fR \fIowner/repo\fR \.\.\. . .br +fisher \fBuninstall\fR \fIpath\fR \.\.\. +. +.br . .SH "DESCRIPTION" Uninstall one or \fImore\fR plugins by \fIname\fR, searching \fB$fisher_index\fR or by \fIurl\fR\. If no arguments are given, read the standard input\. This process is the inverse of Install\. See \fBfisher help install\fR\. @@ -56,7 +59,7 @@ Uninstall all plugins and flush the cache\. . .nf -fisher \-\-cache=base | fisher uninstall \-\-force +fisher \-\-list | fisher uninstall \-\-force . .fi . diff --git a/man/man1/fisher-uninstall.md b/man/man1/fisher-uninstall.md index a66988b..ed9e458 100644 --- a/man/man1/fisher-uninstall.md +++ b/man/man1/fisher-uninstall.md @@ -3,13 +3,14 @@ fisher-uninstall(1) -- Disable / Uninstall Plugins ## SYNOPSIS -fisher `uninstall` [*name* or *url* ...]
+fisher `uninstall` [*name*, *url* or *path* ...]
fisher `uninstall` [`--force`] [`--quiet`] [`--help`]
## USAGE fisher `uninstall` *plugin* ...
fisher `uninstall` *owner/repo* ...
+fisher `uninstall` *path* ...
## DESCRIPTION @@ -35,7 +36,7 @@ Uninstall does not remove any dependencies installed with other plugins. This be * Uninstall all plugins and flush the cache. ``` -fisher --cache=base | fisher uninstall --force +fisher --list | fisher uninstall --force ``` ## SEE ALSO diff --git a/man/man1/fisher-update.1 b/man/man1/fisher-update.1 index 6373fcf..dfe8de6 100644 --- a/man/man1/fisher-update.1 +++ b/man/man1/fisher-update.1 @@ -7,10 +7,10 @@ \fBfisher\-update\fR \- Fisherman Update Manager . .SH "SYNOPSIS" -fisher \fBupdate\fR [\fIname\fR or \fIurl\fR \.\.\.] +fisher \fBupdate\fR [\fIname\fR, \fIurl\fR or \fIpath\fR \.\.\.] . .br -fisher \fBupdate\fR [\fB\-\-me\fR] [\fB\-\-quiet\fR] [\fB\-\-help\fR] +fisher \fBupdate\fR [\fB\-\-quiet\fR] [\fB\-\-help\fR] . .br . @@ -21,20 +21,19 @@ fisher \fBupdate\fR \fIplugin\fR \.\.\. fisher \fBupdate\fR \fIowner/repo\fR \.\.\. . .br +fisher \fBupdate\fR \fIpath\fR \.\.\. +. +.br . .SH "DESCRIPTION" -Update one or \fImore\fR plugins by \fIname\fR, searching \fB$fisher_index\fR or by \fIurl\fR\. If no arguments are given, read the standard input\. If you try to update a plugin that is currently disabled, but available in the cache, it will be updated and then enabled\. +Update one or \fImore\fR plugins by \fIname\fR, searching \fB$fisher_index\fR or by \fIurl\fR\. If no arguments are given, update Fisherman by default\. If you try to update a plugin that is currently disabled, but downloaded to the cache, it will be updated and then enabled\. Use a dash \fB\-\fR to read from the standard input\. . .P -If a plugin is missing dependencies, they will be installed\. If any dependencies are already installed they will not be updated in order to prevent mismatching version issues\. See \fBfisher help fishfile\fR#{\fBPlugins\fR}\. +If a plugin is missing dependencies, they will be installed\. If any dependencies are already installed they will not be updated\. See \fBfisher help fishfile\fR#{\fBPlugins\fR}\. . .SH "OPTIONS" . .TP -\fB\-m\fR \fB\-\-me\fR -Update Fisherman\. -. -.TP \fB\-q\fR \fB\-\-quiet\fR Enable quiet mode\. . @@ -50,7 +49,7 @@ Update all plugins in the cache\. .IP "" 0 . .P -fisher \-\-cache=base | fisher update +fisher \-\-list | fisher update \- . .SH "SEE ALSO" \fBfisher\fR(1) diff --git a/man/man1/fisher-update.md b/man/man1/fisher-update.md index c6a92eb..c1f35d6 100644 --- a/man/man1/fisher-update.md +++ b/man/man1/fisher-update.md @@ -3,25 +3,23 @@ fisher-update(1) -- Fisherman Update Manager ## SYNOPSIS -fisher `update` [*name* or *url* ...]
-fisher `update` [`--me`] [`--quiet`] [`--help`]
+fisher `update` [*name*, *url* or *path* ...]
+fisher `update` [`--quiet`] [`--help`]
## USAGE fisher `update` *plugin* ...
fisher `update` *owner/repo* ...
+fisher `update` *path* ...
## DESCRIPTION -Update one or *more* plugins by *name*, searching `$fisher_index` or by *url*. If no arguments are given, read the standard input. If you try to update a plugin that is currently disabled, but available in the cache, it will be updated and then enabled. +Update one or *more* plugins by *name*, searching `$fisher_index` or by *url*. If no arguments are given, update Fisherman by default. If you try to update a plugin that is currently disabled, but downloaded to the cache, it will be updated and then enabled. Use a dash `-` to read from the standard input. -If a plugin is missing dependencies, they will be installed. If any dependencies are already installed they will not be updated in order to prevent mismatching version issues. See `fisher help fishfile`#{`Plugins`}. +If a plugin is missing dependencies, they will be installed. If any dependencies are already installed they will not be updated. See `fisher help fishfile`#{`Plugins`}. ## OPTIONS -* `-m` `--me`: - Update Fisherman. - * `-q` `--quiet`: Enable quiet mode. @@ -32,7 +30,7 @@ If a plugin is missing dependencies, they will be installed. If any dependencies * Update all plugins in the cache. -fisher --cache=base | fisher update +fisher --list | fisher update - ## SEE ALSO diff --git a/man/man1/fisher.1 b/man/man1/fisher.1 index 8053c6c..e5c2495 100644 --- a/man/man1/fisher.1 +++ b/man/man1/fisher.1 @@ -10,15 +10,16 @@ \fBfisher\fR \fIcommand\fR [\fIoptions\fR] [\fB\-\-version\fR] [\fB\-\-help\fR] . .br +\fBfisher\fR \fB\-\-list\fR +. +.br +\fBfisher\fR \fB\-\-alias\fR[=\fIcommand\fR=[\fIalias\fR[,\.\.\.]]] +. +.br \fBfisher\fR \fB\-\-file\fR=\fIfishfile\fR . .br -\fBfisher\fR \fB\-\-validate\fR=\fIname\fR or \fIurl\fR -. -.br -\fBfisher\fR \fB\-\-cache\fR[=\fIpath\fR] -. -.br +\fBfisher\fR \fB\-\-validate\fR . .SH "DESCRIPTION" Fisherman is a plugin manager for \fBfish\fR(1) that lets you share and reuse code, prompts and configurations easily\. @@ -28,33 +29,37 @@ The following commands are available: \fIinstall\fR, \fIuninstall\fR, \fIupdate\ . .SH "OPTIONS" . -.IP "\(bu" 4 -\fB\-f\fR \fB\-\-file\fR=\fIfishfile\fR: Read \fIfishfile\fR and write contents to standard output\. If \fIfishfile\fR is null or an empty string, your user \fIfishfile\fR in \fB$fisher_config\fR/fishfile will be used instead\. Use a dash \fB\-\fR to force reading from the standard input\. Oh My Fish! bundle files are supported as well\. +.TP +\fB\-\-list\fR +List plugins in the \fB$fisher_cache\fR\. Includes plugins installed using a custom URL\. . -.IP "\(bu" 4 -\fB\-V\fR, \fB\-\-validate\fR=\fIkeyword\fR: Validate a \fIname\fR or \fIurl\fR\. If \fIkeyword\fR resembles a url, the algorithm will attempt to normalize the url by adding / removing missing components\. Otherwise, it will assume \fIkeyword\fR is a potential plugin name and use the following regex \fB^[a\-z]+[\._\-]?[a\-z0\-9]+\fR to validate the string\. This method is used internally to validate user input and support url variations such as \fIowner/repo\fR, \fIgh:owner/repo\fR, \fIbb:owner/repo\fR, etc\. See \fBfisher\fR(7)#{\fBPlugins\fR}\. +.TP +\fB\-a\fR \fB\-\-alias\fR[=\fIcommand\fR=[\fIalias\fR[,\.\.\.]]] +Define one or more comma\-separated \fIalias\fR for \fIcommand\fR using \fB$fisher_alias\fR\. If no value is given, lists all existing aliases\. . -.IP -If \fIkeyword\fR is null or an empty string, \fB\-\-validate\fR reads keyword\fIs\fR from the standard input\. +.TP +\fB\-f\fR \fB\-\-file\fR=\fIfishfile\fR +Read \fIfishfile\fR and display its contents\. If \fIfishfile\fR is null or an empty string, your user \fIfishfile\fR in \fB$fisher_config\fR/fishfile will be used instead\. Use a dash \fB\-\fR to force reading from the standard input\. oh\-my\-fish bundle files are supported as well\. . -.IP "\(bu" 4 -\fB\-\-cache\fR[=\fIbase\fR] Retrieve the path of every plugin downloaded to \fB$fisher_cache\fR\. Includes plugins installed using a custom URL\. Use \-\-cache=\fIbase\fR to select only the name of the plugin\. See \fBbasename\fR(1)\. +.TP +\fB\-V\fR, \fB\-\-validate\fR +Read the standard input and validate a name, url or path\. If the input is a local path, retrieve the absolute path to the closest directory\. If the input resembles a url, normalize the url according to the rules described in \fBfisher help install\fR\. Otherwise, assume the input is a name and use the regex \fB^[a\-z]+[\._\-]?[a\-z0\-9]+\fR to validate the string\. . -.IP "\(bu" 4 -\fB\-v\fR \fB\-\-version\fR: Show version information\. Fisherman\'s current version can be found in the VERSION file at the root of the project\. The version scheme is based in \fBSemantic Versioning\fR and uses Git annotated tags to track releases\. +.TP +\fB\-v\fR \fB\-\-version\fR +Show version information\. Fisherman\'s current version can be found in the VERSION file at the root of the project\. The version scheme is based in \fBSemantic Versioning\fR and uses Git annotated tags to track releases\. . -.IP "\(bu" 4 -\fB\-h\fR \fB\-\-help\fR: Show usage help\. -. -.IP "" 0 +.TP +\fB\-h\fR \fB\-\-help\fR +Show usage help\. . .SH "CUSTOM COMMANDS" -A Fisherman command is a function that you can invoke using the \fBfisher\fR utility\. By convention, any function of the form \fBfisher_\fR is registered as Fisherman command\. You can create plugins that add new commands as well as regular utilities\. See \fBfisher help commands\fR and \fBfisher help plugins\fR for more information\. +A Fisherman command is a function that you can invoke using the \fBfisher\fR utility\. By convention, any function like \fBfisher_\fR is registered as a Fisherman command\. You can create plugins that add new commands this way\. See \fBfisher help commands\fR and \fBfisher help plugins\fR for more information\. . .SH "EXAMPLES" . .IP "\(bu" 4 -Install a plugin\. +Install plugins\. . .IP "" 0 . @@ -62,8 +67,7 @@ Install a plugin\. . .nf -fisher install fishtape -fishtape \-\-help +fisher install fishtape shark . .fi . @@ -83,24 +87,22 @@ fisher \-\-file=path/to/shared/fishfile | fisher install . .IP "" 0 . -.IP "\(bu" 4 -Validate a url\. -. -.IP "" 0 +.TP +Define a few aliases: + . .IP "" 4 . .nf -echo a/b | fisher \-V -> https://github\.com/a/b +fisher \-a uninstall=rm,u,del . .fi . .IP "" 0 . .SH "AUTHORS" -Fisherman was created and it is currently maintained by Jorge Bucaran \fIj@bucaran\.me\fR\. +Fisherman was created by Jorge Bucaran \fIj@bucaran\.me\fR\. . .P See AUTHORS file for a more complete list of contributors\. diff --git a/man/man1/fisher.md b/man/man1/fisher.md index df3ccdb..897a9f0 100644 --- a/man/man1/fisher.md +++ b/man/man1/fisher.md @@ -4,9 +4,10 @@ fisher(1) -- fish plugin manager ## SYNOPSIS `fisher` *command* [*options*] [`--version`] [`--help`]
+`fisher` `--list`
+`fisher` `--alias`[=*command*=[*alias*[,...]]]
`fisher` `--file`=*fishfile*
-`fisher` `--validate`=*name* or *url*
-`fisher` `--cache`[=*path*]
+`fisher` `--validate` ## DESCRIPTION @@ -16,16 +17,17 @@ The following commands are available: *install*, *uninstall*, *update*, *search* ## OPTIONS +* `--list`: + List plugins in the `$fisher_cache`. Includes plugins installed using a custom URL. + +* `-a` `--alias`[=*command*=[*alias*[,...]]]: + Define one or more comma-separated *alias* for *command* using `$fisher_alias`. If no value is given, lists all existing aliases. + * `-f` `--file`=*fishfile*: - Read *fishfile* and write contents to standard output. If *fishfile* is null or an empty string, your user *fishfile* in `$fisher_config`/fishfile will be used instead. Use a dash `-` to force reading from the standard input. Oh My Fish! bundle files are supported as well. + Read *fishfile* and display its contents. If *fishfile* is null or an empty string, your user *fishfile* in `$fisher_config`/fishfile will be used instead. Use a dash `-` to force reading from the standard input. oh-my-fish bundle files are supported as well. -* `-V`, `--validate`=*keyword*: - Validate a *name* or *url*. If *keyword* resembles a url, the algorithm will attempt to normalize the url by adding / removing missing components. Otherwise, it will assume *keyword* is a potential plugin name and use the following regex `^[a-z]+[._-]?[a-z0-9]+` to validate the string. This method is used internally to validate user input and support url variations such as *owner/repo*, *gh:owner/repo*, *bb:owner/repo*, etc. See `fisher`(7)#{`Plugins`}. - - If *keyword* is null or an empty string, `--validate` reads keyword*s* from the standard input. - -* `--cache`[=*base*] - Retrieve the path of every plugin downloaded to `$fisher_cache`. Includes plugins installed using a custom URL. Use --cache=*base* to select only the name of the plugin. See `basename`(1). +* `-V`, `--validate`: + Read the standard input and validate a name, url or path. If the input is a local path, retrieve the absolute path to the closest directory. If the input resembles a url, normalize the url according to the rules described in `fisher help install`. Otherwise, assume the input is a name and use the regex `^[a-z]+[._-]?[a-z0-9]+` to validate the string. * `-v` `--version`: Show version information. Fisherman's current version can be found in the VERSION file at the root of the project. The version scheme is based in `Semantic Versioning` and uses Git annotated tags to track releases. @@ -35,15 +37,14 @@ The following commands are available: *install*, *uninstall*, *update*, *search* ## CUSTOM COMMANDS -A Fisherman command is a function that you can invoke using the `fisher` utility. By convention, any function of the form `fisher_` is registered as Fisherman command. You can create plugins that add new commands as well as regular utilities. See `fisher help commands` and `fisher help plugins` for more information. +A Fisherman command is a function that you can invoke using the `fisher` utility. By convention, any function like `fisher_` is registered as a Fisherman command. You can create plugins that add new commands this way. See `fisher help commands` and `fisher help plugins` for more information. ## EXAMPLES -* Install a plugin. +* Install plugins. ``` -fisher install fishtape -fishtape --help +fisher install fishtape shark ``` * Install plugins from a fishfile or bundle: @@ -52,16 +53,15 @@ fishtape --help fisher --file=path/to/shared/fishfile | fisher install ``` -* Validate a url. +* Define a few aliases: ``` -echo a/b | fisher -V -> https://github.com/a/b +fisher -a uninstall=rm,u,del ``` ## AUTHORS -Fisherman was created and it is currently maintained by Jorge Bucaran *j@bucaran.me*. +Fisherman was created by Jorge Bucaran *j@bucaran.me*. See AUTHORS file for a more complete list of contributors. diff --git a/man/man1/getopts.1 b/man/man1/getopts.1 index f03faec..ed3cbfd 100644 --- a/man/man1/getopts.1 +++ b/man/man1/getopts.1 @@ -15,7 +15,7 @@ .br . .SH "DESCRIPTION" -getopts is a tool to help parsing command\-line arguments\. It is designed to process command line arguments that follow the POSIX Utility Syntax Guidelines\. If no arguments are given it returns \fB1\fR\. +getopts is a command line parser, designed to process command line arguments according to the POSIX Utility Syntax Guidelines\. If no arguments are given it returns \fB1\fR\. . .SH "USAGE" In the following example: @@ -131,7 +131,7 @@ getopts does \fInot\fR read the standard input\. Use getopts to collect options A double dash, \fB\-\-\fR, marks the end of options\. Arguments after this sequence are placed in the default underscore key, \fB_\fR\. . .IP "\(bu" 4 -The getopts described in this document is \fInot\fR equivalent to the getopts \fIbuiltin\fR found in other shells\. This tool is only available for \fBfish\fR(1)\. +The getopts described in this document is \fInot\fR equivalent to the getopts \fIbuiltin\fR found in other shells\. . .IP "" 0 . diff --git a/man/man1/getopts.md b/man/man1/getopts.md index d9244ab..4d9b263 100644 --- a/man/man1/getopts.md +++ b/man/man1/getopts.md @@ -8,7 +8,7 @@ getopts(1) -- Parse CLI options ## DESCRIPTION -getopts is a tool to help parsing command-line arguments. It is designed to process command line arguments that follow the POSIX Utility Syntax Guidelines. If no arguments are given it returns `1`. +getopts is a command line parser, designed to process command line arguments according to the POSIX Utility Syntax Guidelines. If no arguments are given it returns `1`. ## USAGE @@ -97,7 +97,7 @@ end * A double dash, `--`, marks the end of options. Arguments after this sequence are placed in the default underscore key, `_`. -* The getopts described in this document is *not* equivalent to the getopts *builtin* found in other shells. This tool is only available for `fish`(1). +* The getopts described in this document is *not* equivalent to the getopts *builtin* found in other shells. ## AUTHORS diff --git a/man/man5/fisher-fishfile.5 b/man/man5/fisher-fishfile.5 index a6e4046..65fd238 100644 --- a/man/man5/fisher-fishfile.5 +++ b/man/man5/fisher-fishfile.5 @@ -34,7 +34,7 @@ oh\-my\-fish/bobthefish .IP "" 0 . .P -To read fishfiles use \fBfisher \-\-file\fR=\fIfishfile\fR\. This will read \fIfishfile\fR sequentially, writing its contents to the standard output\. Oh My Fish! bundle files are supported as well\. +To read fishfiles use \fBfisher \-\-file\fR=\fIfishfile\fR\. This will read \fIfishfile\fR sequentially, writing its contents to the standard output\. oh-my-fish bundle files are supported as well\. . .P If \fIfishfile\fR is null or an empty string, the global \fIfishfile\fR in \fB$fisher_config\fR/fishfile will be used\. Use a dash \fB\-\fR to force read from standard input\. diff --git a/man/man5/fisher-fishfile.md b/man/man5/fisher-fishfile.md index 887d824..6484964 100644 --- a/man/man5/fisher-fishfile.md +++ b/man/man5/fisher-fishfile.md @@ -22,7 +22,7 @@ fishtape oh-my-fish/bobthefish ``` -To read fishfiles use `fisher --file`=*fishfile*. This will read *fishfile* sequentially, writing its contents to the standard output. Oh My Fish! bundle files are supported as well. +To read fishfiles use `fisher --file`=*fishfile*. This will read *fishfile* sequentially, writing its contents to the standard output. oh-my-fish bundle files are supported as well. If *fishfile* is null or an empty string, the global *fishfile* in `$fisher_config`/fishfile will be used. Use a dash `-` to force read from standard input. diff --git a/man/man7/fisher-faq.7 b/man/man7/fisher-faq.7 index bcfafc6..cedb37b 100644 --- a/man/man7/fisher-faq.7 +++ b/man/man7/fisher-faq.7 @@ -4,7 +4,7 @@ .TH "FISHER\-FAQ" "7" "January 2016" "" "fisherman" . .SH "NAME" -\fBfisher\-faq\fR \- Fisherman Frequently Asked Questions +\fBfisher\-faq\fR \- Frequently Asked Questions . .SH "SYNOPSIS" This document attempts to answer some of Fisherman most frequently asked questions\. Feel free to create a new issue in the Fisherman issue tracker if your question is not answered here\. @@ -50,14 +50,14 @@ There is no technical distinction between plugins, themes, commands, etc\., but .P See \fBfisher help plugins\fR and \fBfisher help commands\fR\. . -.SS "Does Fisherman support Oh My Fish! plugins and themes?" +.SS "Does Fisherman support oh\-my\-fish plugins and themes?" Yes\. To install either a plugin or theme use their URL: . .IP "" 4 . .nf -fisher install omf/{rbenv,hub,theme\-scorphish} +fisher install omf/plugin\-{rbenv,tab} omf/theme\-scorphish . .fi . @@ -87,19 +87,19 @@ end .P See \fB$fisher_home/config\.fish\fR for the full code\. . -.SS "How is Fisherman faster than Oh My Fish!/Wahoo, etc?" +.SS "How is Fisherman faster than oh\-my\-fish/Wahoo, etc?" Fisherman ameliorates the slow shell start problem using a flat dependency tree instead of loading a directory hierarchy per plugin\. This also means that Fisherman performance does not decline depending on the number of plugins installed\. See also \fBfisher\fR(7)#{\fBFlat Tree\fR}\. . -.SS "Why don\'t you contribute your improvements back to Oh My Fish! instead of creating a new project?" -I have contributed back to Oh My Fish! extensively\. See also Oh My Fish! history for August 27, 2015 when another project, Wahoo, was entirely merged with Oh My Fish!\. +.SS "Why don\'t you contribute your improvements back to oh\-my\-fish instead of creating a new project?" +I have contributed back to oh\-my\-fish extensively\. See also oh\-my\-fish history for August 27, 2015 when another project, Wahoo, was entirely merged with oh\-my\-fish\. . .P In addition, Fisherman was built from the ground up using a completely different design, implementation and set of principles\. . .P -Some features include: UNIX familiarity, minimalistic design, flat tree structure, unified plugin architecture, external self\-managed database, cache system, dependency manifest file and compatibility with Oh My Fish!, etc\. See \fBfisher\fR(7)\. +Some features include: UNIX familiarity, minimalistic design, flat tree structure, unified plugin architecture, external self\-managed database, cache system, dependency manifest file and compatibility with oh\-my\-fish, etc\. See \fBfisher\fR(7)\. . -.SS "How can I upgrade from an existing Oh My Fish! or Wahoo installation?" +.SS "How can I upgrade from an existing oh\-my\-fish or Wahoo installation?" Install Fisherman\. . .IP "" 4 @@ -115,7 +115,7 @@ make .IP "" 0 . .P -You can now safely remove Oh My Fish! \fB$OMF_PATH\fR and \fB$OMF_CONFIG\fR\. +You can now safely remove oh\-my\-fish \fB$OMF_PATH\fR and \fB$OMF_CONFIG\fR\. . .P Backup dotfiles and other sensitive data first\. @@ -185,5 +185,5 @@ chsh \-s /bin/another/shell . .IP "" 0 . -.SS "Why is this FAQ similar to the Oh My Fish! FAQ?" +.SS "Why is this FAQ similar to the oh\-my\-fish FAQ?" Because it was written by the same author of Fisherman and Wahoo and some of the questions and answers simply overlap\. diff --git a/man/man7/fisher-faq.md b/man/man7/fisher-faq.md index 4e2deed..d3a7957 100644 --- a/man/man7/fisher-faq.md +++ b/man/man7/fisher-faq.md @@ -1,5 +1,5 @@ -fisher-faq(7) -- Fisherman Frequently Asked Questions -===================================================== +fisher-faq(7) -- Frequently Asked Questions +=========================================== ## SYNOPSIS @@ -50,12 +50,12 @@ There is no technical distinction between plugins, themes, commands, etc., but t See `fisher help plugins` and `fisher help commands`. -### Does Fisherman support Oh My Fish! plugins and themes? +### Does Fisherman support oh-my-fish plugins and themes? Yes. To install either a plugin or theme use their URL: ``` -fisher install omf/{rbenv,hub,theme-scorphish} +fisher install omf/plugin-{rbenv,tab} omf/theme-scorphish ``` You can use the same mechanism to a valid plugin from any given URL. See also `fisher`(7)#{`Compatibility`}. @@ -77,20 +77,20 @@ end See `$fisher_home/config.fish` for the full code. -### How is Fisherman faster than Oh My Fish!/Wahoo, etc? +### How is Fisherman faster than oh-my-fish/Wahoo, etc? Fisherman ameliorates the slow shell start problem using a flat dependency tree instead of loading a directory hierarchy per plugin. This also means that Fisherman performance does not decline depending on the number of plugins installed. See also `fisher`(7)#{`Flat Tree`}. -### Why don't you contribute your improvements back to Oh My Fish! instead of creating a new project? +### Why don't you contribute your improvements back to oh-my-fish instead of creating a new project? -I have contributed back to Oh My Fish! extensively. See also Oh My Fish! history for August 27, 2015 when another project, Wahoo, was entirely merged with Oh My Fish!. +I have contributed back to oh-my-fish extensively. See also oh-my-fish history for August 27, 2015 when another project, Wahoo, was entirely merged with oh-my-fish. In addition, Fisherman was built from the ground up using a completely different design, implementation and set of principles. -Some features include: UNIX familiarity, minimalistic design, flat tree structure, unified plugin architecture, external self-managed database, cache system, dependency manifest file and compatibility with Oh My Fish!, etc. See `fisher`(7). +Some features include: UNIX familiarity, minimalistic design, flat tree structure, unified plugin architecture, external self-managed database, cache system, dependency manifest file and compatibility with oh-my-fish, etc. See `fisher`(7). -### How can I upgrade from an existing Oh My Fish! or Wahoo installation? +### How can I upgrade from an existing oh-my-fish or Wahoo installation? Install Fisherman. @@ -100,7 +100,7 @@ cd fisherman make ``` -You can now safely remove Oh My Fish! `$OMF_PATH` and `$OMF_CONFIG`. +You can now safely remove oh-my-fish `$OMF_PATH` and `$OMF_CONFIG`. Backup dotfiles and other sensitive data first. @@ -141,6 +141,6 @@ chsh -s /bin/another/shell ``` -### Why is this FAQ similar to the Oh My Fish! FAQ? +### Why is this FAQ similar to the oh-my-fish FAQ? Because it was written by the same author of Fisherman and Wahoo and some of the questions and answers simply overlap. diff --git a/man/man7/fisher-plugins.7 b/man/man7/fisher-plugins.7 index 66beb4c..06ed4fa 100644 --- a/man/man7/fisher-plugins.7 +++ b/man/man7/fisher-plugins.7 @@ -105,7 +105,7 @@ end .IP "" 0 . .IP "\(bu" 4 -Add completions\. \fIwtc\fR is simple enough that you could get away without \fB__fish_parse_usage\fR, but more complex utilities, or utilities whose CLI evolves over time, can benefit using automatic completion generation\. Note that in order to use \fB__fish_parse_usage\fR, your command must provide a \fB\-\-help\fR option that prints usage information to standard output\. +Add completions\. \fIwtc\fR is simple enough that you could get away without \fB__fisher_complete\fR, but more complex utilities, or utilities whose CLI evolves over time, can benefit using automatic completion generation\. Note that in order to use \fB__fisher_complete\fR, your command must provide a \fB\-\-help\fR option that prints usage information to standard output\. . .IP \fBmkdir\fR completions @@ -120,7 +120,7 @@ Add completions\. \fIwtc\fR is simple enough that you could get away without \fB .nf set \-l IFS ";" -wtc \-\-help | __fish_parse_usage | while read \-l info long short +wtc \-\-help | __fisher_complete | while read \-l info long short complete \-c wtc \-s "$short" \-l "$long" \-d "$info" end ^C diff --git a/man/man7/fisher-plugins.md b/man/man7/fisher-plugins.md index 2826f96..94b06c3 100644 --- a/man/man7/fisher-plugins.md +++ b/man/man7/fisher-plugins.md @@ -68,14 +68,14 @@ end ^C ``` -* Add completions. *wtc* is simple enough that you could get away without `__fish_parse_usage`, but more complex utilities, or utilities whose CLI evolves over time, can benefit using automatic completion generation. Note that in order to use `__fish_parse_usage`, your command must provide a `--help` option that prints usage information to standard output. +* Add completions. *wtc* is simple enough that you could get away without `__fisher_complete`, but more complex utilities, or utilities whose CLI evolves over time, can benefit using automatic completion generation. Note that in order to use `__fisher_complete`, your command must provide a `--help` option that prints usage information to standard output. `mkdir` completions
`cat` > completions/wtc.fish ``` set -l IFS ";" -wtc --help | __fish_parse_usage | while read -l info long short +wtc --help | __fisher_complete | while read -l info long short complete -c wtc -s "$short" -l "$long" -d "$info" end ^C diff --git a/man/man7/fisher.7 b/man/man7/fisher.7 index 797797c..04dd66a 100644 --- a/man/man7/fisher.7 +++ b/man/man7/fisher.7 @@ -10,7 +10,7 @@ Fisherman is a plugin manager for \fBfish\fR(1) that lets you share and reuse code, prompts and configurations easily\. . .P -Some features include: minimalistic design, flat tree structure, unified plugin architecture, external self\-managed database, cache system, dependency manifest file and compatibility with Oh My Fish! and other frameworks\. +Some features include: minimalistic design, flat tree structure, unified plugin architecture, external self\-managed database, cache system, dependency manifest file and compatibility with oh-my-fish and other frameworks\. . .P This document describes Fisherman features and some of their implementation details\. For usage and command help see also \fBfisher\fR(1)\. @@ -291,16 +291,16 @@ Most commands read the standard input by default when no options are given and p Fisherman also ships with a CLI options parser and a background job wait spinner that you can use to implement your own commands CLI\. See \fBgetopts\fR(1) and \fBwait\fR(1)\. . .SH "COMPATIBILITY" -Fisherman supports Oh My Fish! (Wahoo) themes and plugins by default, but some features are turned off due to performance considerations\. +Fisherman supports oh-my-fish (Wahoo) themes and plugins by default, but some features are turned off due to performance considerations\. . .P -Oh My Fish! evaluates every \fI\.fish\fR file inside the root directory of every plugin during initialization\. This is necessary in order to register any existing \fBinit\fR events and invoke them using fish \fBemit\fR(1)\. +oh-my-fish evaluates every \fI\.fish\fR file inside the root directory of every plugin during initialization\. This is necessary in order to register any existing \fBinit\fR events and invoke them using fish \fBemit\fR(1)\. . .P -Since it is not possible to determine whether a file defines an initialization event without evaluating its contents first, Oh My Fish! sources all \fI\.fish\fR files and then emits events for each plugin\. +Since it is not possible to determine whether a file defines an initialization event without evaluating its contents first, oh-my-fish sources all \fI\.fish\fR files and then emits events for each plugin\. . .P -Not all plugins opt in the initialization mechanism, therefore support for this behavior is turned off by default\. If you would like Fisherman to behave like Oh My Fish! at the start of each session, install the \fBomf\fR compatibility plugin\. +Not all plugins opt in the initialization mechanism, therefore support for this behavior is turned off by default\. If you would like Fisherman to behave like oh-my-fish at the start of each session, install the \fBomf\fR compatibility plugin\. . .IP "" 4 . @@ -313,7 +313,7 @@ fisher install omf .IP "" 0 . .P -This plugin also adds definitions for some of Oh My Fish! Core Library functions\. +This plugin also adds definitions for some of oh-my-fish Core Library functions\. . .SH "SEE ALSO" \fBfisher\fR(1) diff --git a/man/man7/fisher.md b/man/man7/fisher.md index 41cdda0..c5b33bb 100644 --- a/man/man7/fisher.md +++ b/man/man7/fisher.md @@ -5,7 +5,7 @@ fisher(7) -- An Introduction to Fisherman Fisherman is a plugin manager for `fish`(1) that lets you share and reuse code, prompts and configurations easily. -Some features include: minimalistic design, flat tree structure, unified plugin architecture, external self-managed database, cache system, dependency manifest file and compatibility with Oh My Fish! and other frameworks. +Some features include: minimalistic design, flat tree structure, unified plugin architecture, external self-managed database, cache system, dependency manifest file and compatibility with oh-my-fish and other frameworks. This document describes Fisherman features and some of their implementation details. For usage and command help see also `fisher`(1). @@ -180,19 +180,19 @@ Fisherman also ships with a CLI options parser and a background job wait spinner ## COMPATIBILITY -Fisherman supports Oh My Fish! (Wahoo) themes and plugins by default, but some features are turned off due to performance considerations. +Fisherman supports oh-my-fish (Wahoo) themes and plugins by default, but some features are turned off due to performance considerations. -Oh My Fish! evaluates every *.fish* file inside the root directory of every plugin during initialization. This is necessary in order to register any existing `init` events and invoke them using fish `emit`(1). +oh-my-fish evaluates every *.fish* file inside the root directory of every plugin during initialization. This is necessary in order to register any existing `init` events and invoke them using fish `emit`(1). -Since it is not possible to determine whether a file defines an initialization event without evaluating its contents first, Oh My Fish! sources all *.fish* files and then emits events for each plugin. +Since it is not possible to determine whether a file defines an initialization event without evaluating its contents first, oh-my-fish sources all *.fish* files and then emits events for each plugin. -Not all plugins opt in the initialization mechanism, therefore support for this behavior is turned off by default. If you would like Fisherman to behave like Oh My Fish! at the start of each session, install the `omf` compatibility plugin. +Not all plugins opt in the initialization mechanism, therefore support for this behavior is turned off by default. If you would like Fisherman to behave like oh-my-fish at the start of each session, install the `omf` compatibility plugin. ``` fisher install omf ``` -This plugin also adds definitions for some of Oh My Fish! Core Library functions. +This plugin also adds definitions for some of oh-my-fish Core Library functions. ## SEE ALSO diff --git a/share/getopts.awk b/share/getopts.awk deleted file mode 100644 index 630789f..0000000 --- a/share/getopts.awk +++ /dev/null @@ -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() } diff --git a/test/fisher.fish b/test/fisher.fish index 604d529..d165a1c 100644 --- a/test/fisher.fish +++ b/test/fisher.fish @@ -21,8 +21,8 @@ test "read a fishfile using --file" (fisher --file=$fishfile) = foo bar baz github/foo/bar end -test "fisher --cache=base retrieves plugin names in the cache" - (fisher --cache=base) = ( +test "fisher --list retrieves plugin names in the cache" + (fisher --list) = ( for file in $fisher_cache/* basename $file end) @@ -45,7 +45,7 @@ test "evaluate \$fisher_alias= as aliases" end test "display usage" - (fisher | sed 1q) = "usage: fisher [] [--version] [--help]" + (fisher | sed 3q | xargs) = "usage: fisher [--version] [--help] [--list] [--quiet] [-a =alias[,...]] [-f ] []" end test "display help information about 'help' at the bottom" diff --git a/test/help.fish b/test/help.fish index 54057ef..86485c7 100644 --- a/test/help.fish +++ b/test/help.fish @@ -22,11 +22,11 @@ test "help wraps `fisher` w/o arguments" end test "help --all shows commands and guides" - ! -z (fisher help --all | grep -E 'Fisherman commands:$|Fisherman guides:$' | xargs) + ! -z (fisher help --all | grep -E 'Available Commands:$|Other Documentation:$' | xargs) end test "help --guides shows guides" - ! -z (fisher help --guides | grep -E 'Fisherman guides:$' | xargs) + ! -z (fisher help --guides | grep -E 'Other Documentation:$' | xargs) end test "help --usage shows command usage info" @@ -38,3 +38,8 @@ for i in $sections (fisher help $name | xargs) = $name end end + +test "display usage help" + (fisher help --commands=bare | fisher help --usage | xargs + ) = "usage: fisher help [] [--all] [--guides] [--help] -a --all List available documentation -g --guides List available guides -u --usage[=] Display command usage help -h --help Show usage help usage: fisher install [ ...] [--link] [--quiet] [--help] -s --link Install as symbolic links -q --quiet Enable quiet mode -h --help Show usage help usage: fisher search [] [--select=] [--quiet] [--or|--and] [--field=] [--help] -s --select= Select all, cache or remote plugins -f --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 usage: fisher uninstall [ ...] [--force] [--quiet] [--help] -f --force Delete copy from cache -q --quiet Enable quiet mode -h --help Show usage help usage: fisher update [ ...] [--quiet] [--help] -q --quiet Enable quiet mode -h --help Show usage help" +end diff --git a/test/install.fish b/test/install.fish index 126d459..fa41b24 100644 --- a/test/install.fish +++ b/test/install.fish @@ -35,7 +35,7 @@ test "adds installed plugins to fishfile" end test "downloads plugin repos to cache" - (fisher --cache=base) = $names + (fisher --list) = $names end test "download INDEX copy to the cache" diff --git a/test/other.fish b/test/other.fish deleted file mode 100644 index 0247f18..0000000 --- a/test/other.fish +++ /dev/null @@ -1,19 +0,0 @@ -test "display help help" - (fisher help --help | xargs) = "usage: fisher help [] [--all] [--guides] [--usage[=]] [--help] -a --all List commands and guides -g --guides List documentation guides -u --usage[=] Display command usage help -h --help Show usage help" -end - -test "display install help" - (fisher install --help | xargs) = "usage: fisher install [ ...] [--quiet] [--help] -q --quiet Enable quiet mode -h --help Show usage help" -end - -test "display search help" - (fisher search --help | xargs) = "usage: fisher search [] [--select=] [--field=] [--or|--and] [--quiet] [--help] -s --select= Select all, cache or remote plugins -f --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 [ ...] [--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 [ ...] [--me] [--quiet] [--help] -m --me Update Fisherman -q --quiet Enable quiet mode -h --help Show usage help" -end diff --git a/test/update.fish b/test/update.fish index 723cd7d..811854a 100644 --- a/test/update.fish +++ b/test/update.fish @@ -29,7 +29,6 @@ function -S setup fisher_mock_repos $source2/$name - git -C $fisher_cache/$name remote rm origin git -C $fisher_cache/$name remote add origin file://$source2/$name end diff --git a/test/validate.fish b/test/validate.fish index eeb75ca..e95600c 100644 --- a/test/validate.fish +++ b/test/validate.fish @@ -7,57 +7,79 @@ function -S setup end test "validate names" - $id[1] = (fisher --validate=$id[1]) + $id[1] = (printf "%s\n" $id[1] | fisher --validate) end test "validate uris" - $fisher_default_host/$id[1]/$id[2] = (fisher --validate=$id[1]/$id[2]) + $fisher_default_host/$id[1]/$id[2] = ( + printf "%s\n" $id[1]/$id[2] | fisher --validate) end test "validate names may end with a number" - "a0" = (fisher --validate=a0) + "a0" = (printf "%s\n" a0 | fisher --validate) end test "validate names may start in uppercase" - -z (fisher --validate=A) + -z (printf "%s\n" A | fisher --validate) end test "validate names may not start with a number" - -z (fisher --validate=0abc) + -z (printf "%s\n" 0abc | fisher --validate) end test "supress validation output" - -z (fisher -q --validate=$id[1]) + -z (printf "%s\n" $id[1] | fisher --validate --quiet) end test "remove `/' from uris" - $fisher_default_host/$id[1]/$id[2] = (fisher --validate=$id[1]/$id[2]/) + $fisher_default_host/$id[1]/$id[2] = ( + printf "%s\n" $id[1]/$id[2]/ | fisher --validate) end test "remove `.git' from uris" - $fisher_default_host/$id[1]/$id[2] = (fisher --validate=$id[1]/$id[2].git) + $fisher_default_host/$id[1]/$id[2] = ( + printf "%s\n" $id[1]/$id[2].git | fisher --validate) end test "file:/// uris" - ! -z (fisher --validate=file:///$id[1]/$id[2].git) + ! -z (printf "%s\n" file:///$id[1]/$id[2].git | fisher --validate) end test "id/id uris" - ! -z (fisher --validate=$id[1]/$id[2].git) + ! -z (printf "%s\n" $id[1]/$id[2].git | fisher --validate) end test "short owner/repo uris" - https://github.com/$id[1]/$id[2] = (fisher --validate=github/$id[1]/$id[2]) + https://github.com/$id[1]/$id[2] = ( + printf "%s\n" github/$id[1]/$id[2] | fisher --validate) end test "short $short:owner/repo uris" - https://github.com/$id[1]/$id[2] = (fisher --validate=gh:$id[1]/$id[2]) + https://github.com/$id[1]/$id[2] = ( + printf "%s\n" gh:$id[1]/$id[2] | fisher --validate) end test "short bitbucket urls uris" - https://bitbucket.org/$id[1]/$id[2] = (fisher --validate=bb:$id[1]/$id[2]) + https://bitbucket.org/$id[1]/$id[2] = ( + printf "%s\n" bb:$id[1]/$id[2] | fisher --validate) end test "short gitlab urls uris" - https://gitlab.com/$id[1]/$id[2] = (fisher --validate=gl:$id[1]/$id[2]) + https://gitlab.com/$id[1]/$id[2] = ( + printf "%s\n" gl:$id[1]/$id[2] | fisher --validate) +end + +test "omf: urls" + https://github.com/oh-my-fish/theme-default = ( + printf "%s\n" omf:theme-default | fisher --validate) +end + +test "omf/ urls" + https://github.com/oh-my-fish/theme-default = ( + printf "%s\n" omf/theme-default | fisher --validate) +end + +test "urls with a period" + https://github.com/oh-my-fish/theme-cmorrell.com = ( + printf "%s\n" omf/theme-cmorrell.com | fisher --validate) end