diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a14c6d..c810760 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,28 @@ # Change Log +* [0.3.1](#031) * [0.3.0](#030) * [0.2.0](#020) * [0.1.0](#010) -## [0.3.0][v030] - 2016-01-05 +## [0.3.0][v030] - 2016-01-08 + +> This patch contains several amends for 0.3.0 and other minor documentation corrections. + +* Major documentation revision and rewrite. + +* `fisher help` shows `fisher(1)` by default now. + +* Fix a critical bug that was causing `fisher uninstall --force` to remove _not_ the symbolic link, but the actual files. Closes #24 + +* Rename `orphan` tag to `custom` for plugins installed using a custom URL. + +* :warning: Remove `fisher --link` flag and create symbolic links by default for local paths. The user does not have to worry about symbolic links or whether the copy is as symbolic link or not anymore. If the user tries to install a local path, then the best thing to do is to create a symbolic link. This also eliminates the need to call update. + +* :warning: Remove `fisher --cache` and `fisher --validate`. Now, that these options are separated into their own function and they are intentionally private, there is no need for them. + +## [0.3.0][v030] - 2016-01-08 > 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. @@ -65,7 +82,7 @@ * 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 +* 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 local path of the form `file:///` it will pass it as is. * 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. @@ -80,7 +97,7 @@ * ~~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. +* 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_~~ **custom** 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. * ~~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.~~ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 6866339..1436f58 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -35,7 +35,7 @@ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting a project maintainer at [Fisherman][email]. All +reported by contacting a project maintainer at [hi@fisherman.sh](mailto:hi@fisherman.sh). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an @@ -50,6 +50,5 @@ version 1.3.0, available at -[email]: mailto:j@bucaran.me [version]: http://contributor-covenant.org/version/1/3/0/ [homepage]: http://contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c8fe1f2..9f381c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,8 @@ # Contributing to Fisherman -You can start contributing right away: +[![Wharf][wharf-badge]][wharf-link] -* [Join][join] the community. -* [Spread][tweet] the voice. -* Report [bugs][bugs]. - -If you are looking for other ways to help, peruse [open issues][issues]. If you are already working on something, feel free to send us a PR. +If you are looking for ways to help, peruse the [open issues][issues]. If you are already working on something, feel free to send us a PR. ## Guidelines @@ -19,23 +15,31 @@ If you are looking for other ways to help, peruse [open issues][issues]. If you * Follow the [seven rules][seven-rules] of a great git commit message. -## Addons +## Plugins Third-party plugins are essential for keeping this project exciting. To learn how to create your own plugins and other extensions see `fisher help plugins`. To browse the available content use `fisher search` or see the [Fisherman Index][fisher-index]. +:anchor: + + -[org]: https://github.com/fisherman -[join]: https://gitter.im/fisherman/wharf -[bugs]: https://github.com/fisherman/fisherman/issues -[issues]: https://github.com/fisherman/fisherman/issues?q=is%3Aopen+is%3Aissue -[fishtape]: https://github.com/fisherman/fishtape -[fish-docs]: http://fishshell.com/docs/current/index.html -[seven-rules]: http://chris.beams.io/posts/git-commit/#seven-rules +[org]: https://github.com/fisherman + +[bugs]: https://github.com/fisherman/fisherman/issues + +[issues]: https://github.com/fisherman/fisherman/issues?q=is%3Aopen+is%3Aissue + +[fishtape]: https://github.com/fisherman/fishtape + +[fish-docs]: http://fishshell.com/docs/current/index.html + +[seven-rules]: http://chris.beams.io/posts/git-commit/#seven-rules + [fisher-index]: https://github.com/fisherman/fisher-index -[tweet]: https://twitter.com/intent/tweet?url=https%3A%2F%2Fgit.io%2Ffisher&via=jbucaran&text=Check+out+%23Fisherman+for+the+%23fishshell +[wharf-link]: https://fisherman-wharf.herokuapp.com/ -:anchor: +[wharf-badge]: https://img.shields.io/badge/wharf-join%20the%20chat-00cc99.svg?style=flat-square diff --git a/Makefile b/Makefile index 1722551..02daa31 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,8 @@ all: $(FISH_CONFIG) $(FISHER_CACHE) $(AUTHORS) $(DOCS) 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' + @$(call MSG,"Reset your shell and type 'fisher ' to use Fisherman") + @fish -c "fisher help -a" | sed -n '3,$$p' test: @fish -c "fishtape test/*.fish" @@ -76,5 +76,4 @@ $(AUTHORS): $(FISHER_HOME) sed -E 's/([^<>]+)<([^<>]*)>/* \1 \<[\2](mailto:\2)\>/' >> $@ %.1 %.5 %.7: %.md - @echo "Creating the documentation..." - -@ronn --manual=fisherman --roff $? 1>&2 2> /dev/null + -@ronn --manual=fisherman --roff $? 1>&2 2> /dev/null diff --git a/README.md b/README.md index 7388239..2100b87 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ Features include a flat tree structure, external self-managed database, cache sy git clone https://github.com/fisherman/fisherman cd fisherman make -fisher help ``` ## Contributing diff --git a/completions/fisher.fish b/completions/fisher.fish index 125b24e..1bb4d86 100644 --- a/completions/fisher.fish +++ b/completions/fisher.fish @@ -1,31 +1,29 @@ -complete -xc fisher -d "Fisherman" +complete -xc fisher -d "Ahoy! Fisherman" + 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" +complete -c fisher -n "__fish_use_subcommand" -s f -l file -d "Read a fishfile" +complete -c fisher -n "__fish_use_subcommand" -s h -l help -d "Display help" +complete -c fisher -n "__fish_use_subcommand" -s a -l alias -d "Define command aliases" +complete -c fisher -n "__fish_use_subcommand" -s v -l version -d "Show version information" 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 cmd info - complete -c fisher -n "__fish_seen_subcommand_from help" -a $func -d "$info" + complete -c fisher -n "__fish_seen_subcommand_from help" -a $cmd -d "$info" if test $option = guides continue end - complete -c fisher -n "__fish_use_subcommand" -a $func -d "$info" + complete -c fisher -n "__fish_use_subcommand" -a $cmd -d "$info" - 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" + fisher_help --usage=$cmd | __fisher_complete OFS=';' | while read -l 1 2 3 + complete -c fisher -n "__fish_seen_subcommand_from $cmd" -s "$3" -l "$2" -d "$1" end end end -if test -e $fisher_cache/.index - __fisher_complete_cache update uninstall - __fisher_complete_remote install -end +__fisher_complete_cache update uninstall +__fisher_complete_remote install diff --git a/completions/wait.fish b/completions/wait.fish index 697373c..333b543 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 | __fisher_complete | while read -l 1 2 3 +wait -h | __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 cadc112..b270e72 100644 --- a/config.fish +++ b/config.fish @@ -11,3 +11,7 @@ set fish_complete_path {$fisher_config,$fisher_home}/completions $fish_complete_ for file in $fisher_config/conf.d/*.config.fish source $file end + +function d + printf "((%s))\n" $argv >&2 +end diff --git a/functions/__fisher_alias.fish b/functions/__fisher_alias.fish index 7112c13..52e50ba 100644 --- a/functions/__fisher_alias.fish +++ b/functions/__fisher_alias.fish @@ -1,4 +1,4 @@ -function __fisher_alias -a value -d "Define one or more comma-separated command aliases." +function __fisher_alias -a value -d "Define command aliases" switch "$value" case "" if test -z "$fisher_alias" diff --git a/functions/__fisher_cache.fish b/functions/__fisher_cache.fish index 82636d5..8a74627 100644 --- a/functions/__fisher_cache.fish +++ b/functions/__fisher_cache.fish @@ -1,8 +1,18 @@ -function __fisher_cache -d "Calculate path of a name, url or path relative to the cache" +function __fisher_cache -a error -d "Get plugin in cache from a name, url or path" + if test -z "$error" + set error /dev/stderr + end + while read --prompt="" -l item switch "$item" case file:///\* - printf "%s\n" $item + for file in $fisher_cache/* + switch "$item" + case file://(readlink $file) + printf "%s\n" $file + break + end + end case \*/\* for file in $fisher_cache/* @@ -14,7 +24,18 @@ function __fisher_cache -d "Calculate path of a name, url or path relative to th end case \* - printf "%s\n" $fisher_cache/$item + set item $fisher_cache/$item + if test -d "$item" + printf "%s\n" $item + end + + end | read -l path + + if test -z "$path" + printf "fisher: Avast! '%s' is not in the cache\n" $item > $error + continue end + + printf "%s\n" $path end end diff --git a/functions/__fisher_complete.fish b/functions/__fisher_complete.fish index cac6ab0..cbdde5e 100644 --- a/functions/__fisher_complete.fish +++ b/functions/__fisher_complete.fish @@ -1,5 +1,5 @@ # Usage -# __fisher_complete [awk_var=value] [--help] +# __fisher_complete [=value] [--help] # # Example # set -l IFS \t diff --git a/functions/__fisher_file.fish b/functions/__fisher_file.fish index 06a9da8..80da545 100644 --- a/functions/__fisher_file.fish +++ b/functions/__fisher_file.fish @@ -1,8 +1,8 @@ -function __fisher_file -a file -d "Read a fishfile and display its contents" +function __fisher_file -a file -d "Read a fishfiles" switch "$file" case "" set file $fisher_config/fishfile - + case "-" set file /dev/stdin end @@ -15,5 +15,5 @@ function __fisher_file -a file -d "Read a fishfile and display its contents" if (!duplicates[$1]++) printf("%s\n", $1) } - ' $file + ' $argv end diff --git a/functions/__fisher_name.fish b/functions/__fisher_name.fish index fc9668e..496535d 100644 --- a/functions/__fisher_name.fish +++ b/functions/__fisher_name.fish @@ -1,3 +1,3 @@ -function __fisher_name -d "Generate a pretty name from a plugin path or URL" +function __fisher_name -d "Create 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 index fbdc750..d72dd64 100644 --- a/functions/__fisher_validate.fish +++ b/functions/__fisher_validate.fish @@ -8,12 +8,12 @@ function __fisher_validate -d "Validate a name, url or path" while read -lp "" item switch "$item" case \*..\* /. / - continue + return 1 end if test -e "$item" - if test $item = $HOME - continue + if test $item = $HOME -o $HOME = $PWD + return 1 end if test -f "$item" diff --git a/functions/fisher.fish b/functions/fisher.fish index 1640b6a..714b69a 100644 --- a/functions/fisher.fish +++ b/functions/fisher.fish @@ -27,9 +27,6 @@ function fisher -d "Fish Shell Plugin Manager" case l list set option list - case c cache - set option cache - case f file set option file set value $2 @@ -77,24 +74,15 @@ function fisher -d "Fish Shell Plugin Manager" return 1 end - case validate - __fisher_validate | grep $quiet - case list __fisher_list - case cache - __fisher_cache - case file __fisher_file "$value" case alias __fisher_alias $alias - case name - __fisher_name - case version sed 's/^/fisher version /;q' $fisher_home/VERSION @@ -103,9 +91,7 @@ function fisher -d "Fish Shell Plugin Manager" set value commands end - printf "usage: fisher [--version] [--help] [--list] [--quiet]\n" - printf " [-a =alias[,...]] [-f ]\n" - printf " []\n\n" + printf "usage: fisher [] [--version] [--help]\n\n" switch commands case $value diff --git a/functions/fisher_help.fish b/functions/fisher_help.fish index 8467419..fb28d51 100644 --- a/functions/fisher_help.fish +++ b/functions/fisher_help.fish @@ -1,6 +1,6 @@ -function fisher_help -d "Display Help Information" +function fisher_help -d "Show Help" if not set -q argv[1] - fisher --help + man fisher return 1 end @@ -29,12 +29,15 @@ function fisher_help -d "Display Help Information" set option usage set value $value $2 - case h help + case help + set option help + + case h printf "usage: fisher help [] [--all] [--guides] [--help]\n\n" printf " -a --all List available documentation \n" printf " -g --guides List available guides \n" - printf " -u --usage[=] Display command usage help \n" + printf " -u --usage[=] Display command usage \n" printf " -h --help Show usage help \n" return @@ -50,12 +53,17 @@ function fisher_help -d "Display Help Information" end switch "$option" + case help + fisher help help + case manual switch "$value" - case fisherman - man $value 7 - case fisher me @ + case fisherman fisher-7 7-fisher + man 7 fisher + + case fisher me man fisher + case \* man fisher-$value end @@ -64,7 +72,7 @@ function fisher_help -d "Display Help Information" if test -z "$value" sed -E 's/^ *([^ ]+).*/\1/' | while read -l value if functions -q fisher_$value - fisher $value --help + fisher $value -h end end else diff --git a/functions/fisher_install.fish b/functions/fisher_install.fish index 2ee8328..f64282e 100644 --- a/functions/fisher_install.fish +++ b/functions/fisher_install.fish @@ -1,4 +1,4 @@ -function fisher_install -d "Enable / Install one or more plugins" +function fisher_install -d "Install Plugins" set -l items set -l option set -l error /dev/stderr @@ -8,44 +8,47 @@ function fisher_install -d "Enable / Install one or more 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 [ ...] [--link] [--quiet]\n" - printf " [--help]\n\n" + case help + set option help + + case h + printf "usage: fisher install [] [--quiet] [--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: Ahoy! '%s' is not a valid option\n" $1 >& 2 - fisher_install --help >& 2 + fisher_install -h >& 2 return 1 end end + switch "$option" + case help + fisher help install + return + end + + set -l time (date +%s) set -l count 0 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 - - end | __fisher_validate | while read -l item switch "$item" case \*/\* printf "%s %s\n" $item ( - if not fisher_search --url=$item --name + if not fisher_search --name --url=$item printf "%s\n" $item | __fisher_name end) @@ -70,27 +73,22 @@ function fisher_install -d "Enable / Install one or more plugins" printf ">> %s\n" $name > $error case \* - printf "(%s of %s) >> %s\n" $index $total $name > $error - set index (math $index + 1) + printf "(%s of %s) >> %s\n" $index $total $name > $error end mkdir -p $fisher_config/{cache,functions,completions,conf.d,man} set -l path $fisher_cache/$name - if not test -e $path - switch "$url" - case file:///\* - set url (printf "%s\n" $url | sed 's|file://||') - - if test "$option" = link - ln -sF $url $path - else - cp -rf $url $path - end + switch "$url" + case file:///\* + if test ! -e $path + ln -sfF (printf "%s\n" $url | sed 's|file://||') $path + end - case \* + case \* + if test ! -e $path if not wait --spin=pipe --log=$fisher_error_log " git clone --quiet --depth 1 $url $path" @@ -103,7 +101,7 @@ function fisher_install -d "Enable / Install one or more plugins" continue end - end + end end if test -L $path @@ -155,14 +153,14 @@ function fisher_install -d "Enable / Install one or more plugins" switch $base case \*\?.config.fish if test "$option" = link - ln -sF $file $fisher_config/conf.d/$base + ln -sfF $file $fisher_config/conf.d/$base else cp -f $file $fisher_config/conf.d/$base end case \* if test "$option" = link - ln -sF $file $fisher_config/functions/$base + ln -sfF $file $fisher_config/functions/$base else cp -f $file $fisher_config/functions/$base end @@ -171,7 +169,7 @@ function fisher_install -d "Enable / Install one or more plugins" if test "$option" = link for file in $path/completions/*.fish - ln -sF $file $fisher_config/completions/(basename $file) + ln -sfF $file $fisher_config/completions/(basename $file) end else cp -f $path/completions/*.fish $fisher_config/completions/ ^ /dev/null @@ -184,7 +182,7 @@ function fisher_install -d "Enable / Install one or more plugins" for file in $path/man/man$n/*.$n if test "$option" = link - ln -sF $file $fisher_config/man/man$n + ln -sfF $file $fisher_config/man/man$n else cp -f $file $fisher_config/man/man$n end @@ -199,7 +197,7 @@ function fisher_install -d "Enable / Install one or more plugins" set -l item $name - if fisher_search --name=$name --and --tag=orphan --quiet + if fisher_search --name=$name --and --tag=local --quiet set item $url end @@ -212,12 +210,12 @@ function fisher_install -d "Enable / Install one or more plugins" printf "%s\n" "$item" >> $file end - set elapsed (math (date +%s) - $elapsed) + set time (math (date +%s) - $time) 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 + printf "Aye! %d plugin/s installed in %0.fs\n" $count $time > $error end diff --git a/functions/fisher_search.fish b/functions/fisher_search.fish index 10f02f4..4f6ac6b 100644 --- a/functions/fisher_search.fish +++ b/functions/fisher_search.fish @@ -1,4 +1,5 @@ -function fisher_search -d "Search Fisherman Index" +function fisher_search -d "Search Plugins" + set -l option set -l select all set -l fields set -l join "||" @@ -16,7 +17,7 @@ function fisher_search -d "Search Fisherman Index" set 1 url set -l url (printf "%s\n" $2 | __fisher_validate) - if not test -z "$url" + if test ! -z "$url" set 2 $url end @@ -74,14 +75,16 @@ function fisher_search -d "Search Fisherman Index" case q quiet set quiet 1 - case h help - printf "usage: fisher search [] [--select=] [--quiet]\n" + case help + set option help + + case h + 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" - printf " -a --and Join query with AND operator \n" - printf " -o --or Join query with OR operator \n" + printf " -o --or | -a --and Join query with AND/OR operator \n" printf " -q --quiet Enable quiet mode \n" printf " -h --help Show usage help \n" return @@ -93,6 +96,12 @@ function fisher_search -d "Search Fisherman Index" end end + switch "$option" + case help + fisher help search + return + end + if test -z "$fields[1]" set fields '$0' end @@ -112,16 +121,17 @@ function fisher_search -d "Search Fisherman Index" end end - if not test -s $index + if test ! -s $index printf "fisher: '%s' invalid path or url\n" $index >& 2 return 1 end set -l cache (__fisher_list) - awk -v FS='\n' -v RS='' -v cache_items="$cache" ' + + awk -v FS='\n' -v RS='' -v items="$cache" ' BEGIN { - split(cache_items, cache, " ") + split(items, cache, " ") } /^ *#/ { next } { @@ -138,37 +148,47 @@ function fisher_search -d "Search Fisherman Index" } } - ' $index | while read -l orphan - git -C $fisher_cache/$orphan ls-remote --get-url \ - | read -l url - - printf "%s\n" $url \ - | sed -E ' - s|^https?://|| - s|^github\.com|| - s|^bitbucket.org|bb:| - s|^gitlab.com|gl:| - s|^/||' \ - | read -l info - - git -C $fisher_cache/$orphan show -s --format='%ae;%an' ( - git -C $fisher_cache/$orphan rev-list --max-parents=0 HEAD) \ - | awk -v FS=';' '{ printf("%s\n", ($1 ? $1 : $2 ? $2 : "unknown")) }' \ - | read -l author - - set -l tags orphan - - for tag in theme plugin oh-my-fish config - if printf "%s\n" "$url" | grep -q $tag - switch "$tag" - case oh-my-fish - set tag omf + ' $index | while read -l item + + set -l url + set -l info + set -l tags + set -l author + + if test -e $fisher_cache/$item/.git + set tags custom + + set url (git -C $fisher_cache/$item ls-remote --get-url) + + set info (printf "%s\n" $url \ + | sed -E ' + s|^https?://|| + s|^github\.com|| + s|^bitbucket.org|bb:| + s|^gitlab.com|gl:| + s|^/||') + + set author (printf "%s\n" $url | sed 's|/[^/]*$||;s|.*/||') + + for tag in theme plugin config + switch "$url" + case \*$tag\* + set tags $tag $tags end - set tags $tag $tags end + else + set tags local + set url $fisher_cache/$item + + if test -L $url + set url (readlink $url) + end + + set author $USER + set info "$author/$item" end - printf "\n%s\n%s\n%s\n%s\n%s\n\n" "$orphan" "$url" "$info" "$tags" "$author" + printf "\n%s\n%s\n%s\n%s\n%s\n\n" "$item" "$url" "$info" "$tags" "$author" end cat $index @@ -177,7 +197,7 @@ function fisher_search -d "Search Fisherman Index" fisher_search --index=$index --and --name!=(__fisher_list) case cache - __fisher_list | read -laz cache + set -l cache (__fisher_list) if test -z "$cache" return 1 diff --git a/functions/fisher_uninstall.fish b/functions/fisher_uninstall.fish index 9e2ef51..83a7cfd 100644 --- a/functions/fisher_uninstall.fish +++ b/functions/fisher_uninstall.fish @@ -1,24 +1,24 @@ -function fisher_uninstall -d "Disable / Uninstall Plugins" - set -l option - set -l items +function fisher_uninstall -d "Uninstall Plugins" set -l error /dev/stderr + set -l items + set -l option getopts $argv | while read -l 1 2 switch "$1" case _ set items $items $2 - case a all - set option $option all - case f force set option $option force case q quiet set error /dev/null - case help h - printf "usage: fisher uninstall [ ...] [--force] [--quiet] [--help]\n\n" + case help + set option help + + case h + printf "usage: fisher uninstall [] [--force] [--quiet] [--help]\n\n" printf " -f --force Delete copy from cache \n" printf " -q --quiet Enable quiet mode \n" @@ -27,32 +27,28 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" case \* printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 - fisher_uninstall --help >& 2 + fisher_uninstall -h >& 2 return 1 end end + switch "$option" + case help + fisher help uninstall + return + end + + set -l time (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_cache | while read -l path - - if not test -d "$path" - 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 + end | __fisher_validate | __fisher_cache $error | while read -l path set -l name (printf "%s\n" $path | __fisher_name) @@ -63,9 +59,8 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" printf ">> %s\n" $name > $error case \* - printf "(%s of %s) >> %s\n" (math 1 + $index) $total $name > $error - set index (math $index + 1) + printf "(%s of %s) >> %s\n" (math 1 + $index) $total $name > $error end for file in $path/{*,functions{/*,/**/*}}.fish @@ -125,12 +120,12 @@ function fisher_uninstall -d "Disable / Uninstall Plugins" mv -f $tmp $file end - set elapsed (math (date +%s) - $elapsed) + set time (math (date +%s) - $time) 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 + printf "Aye! %d plugin/s uninstalled in %0.fs\n" > $error $count $time end diff --git a/functions/fisher_update.fish b/functions/fisher_update.fish index 0911f55..38749a7 100644 --- a/functions/fisher_update.fish +++ b/functions/fisher_update.fish @@ -1,4 +1,4 @@ -function fisher_update -d "Fisherman Update Manager" +function fisher_update -d "Update Plugins and Fisherman" set -l path set -l items set -l option self @@ -20,8 +20,11 @@ function fisher_update -d "Fisherman Update Manager" case q quiet set error $2 - case help h - printf "usage: fisher update [ ...] [--quiet] [--help]\n\n" + case help + set option help + + case h + printf "usage: fisher update [] [--quiet] [--help]\n\n" printf " -q --quiet Enable quiet mode\n" printf " -h --help Show usage help \n" @@ -29,11 +32,17 @@ function fisher_update -d "Fisherman Update Manager" case \* printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2 - fisher_update --help >& 2 + fisher_update -h >& 2 return 1 end end + switch "$option" + case help + fisher help update + return + end + if test -z "$error" set error /dev/null end @@ -67,41 +76,30 @@ function fisher_update -d "Fisherman Update Manager" rm -f $index case self - set -l elapsed (date +%s) + set -l time (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) - $elapsed) > $error + printf "Done without errors (%0.fs)\n" (math (date +%s) - $time) > $error case \* + set -l time (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_cache | while read -l path - - if not test -d "$path" - switch "$path" - case file:///\* - case \* - printf "fisher: '%s' path not found\n" $path > $error - continue - end - end + + end | __fisher_validate | __fisher_cache $error | while read -l path set -l name (printf "%s\n" $path | __fisher_name) @@ -112,35 +110,30 @@ function fisher_update -d "Fisherman Update Manager" printf ">> %s\n" $name > $error case \* - printf "(%s of %s) >> %s\n" $index $total $name > $error - set index (math $index + 1) + printf "(%s of %s) >> %s\n" $index $total $name > $error end - 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 + if not fisher_update --path=$path --quiet + if test ! -L $path + sed -nE 's/.*(error|fatal): (.*)/error: \2/p + ' $fisher_error_log > $error + continue + end end - fisher install --quiet -- (printf "%s\n" $name | __fisher_name) + fisher install --quiet -- $name set count (math $count + 1) end - set elapsed (math (date +%s) - $elapsed) + set time (math (date +%s) - $time) 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 + printf "Aye! %d plugin/s updated in %0.fs\n" > $error $count $time end end diff --git a/functions/wait.fish b/functions/wait.fish index 265fa14..d6ed1bc 100644 --- a/functions/wait.fish +++ b/functions/wait.fish @@ -1,4 +1,5 @@ function wait -d "Run commands and wait with a spin" + set -l option set -l commands set -l spinners set -l time 0.03 @@ -23,7 +24,10 @@ function wait -d "Run commands and wait with a spin" case f format set format $2 - case h help + case help + set option help + + case h printf "usage: wait [--spin=