refactor: remove ability to rename fisher command itself

This commit is contained in:
Jorge Bucaran 2018-09-11 09:07:25 +09:00
parent d265de6ef6
commit fa4eec9b2a
No known key found for this signature in database
GPG key ID: E54BA3C0E646DB30
3 changed files with 54 additions and 70 deletions

View file

@ -8,4 +8,3 @@ script:
- fish -c "f --version" - fish -c "f --version"
- fish -c "f -h" - fish -c "f -h"
- fish -c "f z; f ls" - fish -c "f z; f ls"
- fish -c "f ls-remote"

View file

@ -1,4 +1,4 @@
Copyright © 2016-present [Jorge Bucaran](https://github.com/JorgeBucaran) Copyright © 2016-present [Jorge Bucaran](https://github.com/jorgebucaran)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,19 +1,4 @@
if not set -q fisher_cmd_name function fisher -d "fish plugin manager"
status --current-filename | command awk '
{
if (n = split($0, parts, "/")) {
gsub(/\.fish$/, "", parts[n])
print(parts[n])
}
}
' | read -gx fisher_cmd_name
end
if test -z "$fisher_cmd_name"
set -gx fisher_cmd_name "fisher"
end
function $fisher_cmd_name -d "fish plugin manager"
switch "$FISH_VERSION" switch "$FISH_VERSION"
case 2.1.2 2.1.1 2.1.0 2.0.0 case 2.1.2 2.1.1 2.1.0 2.0.0
echo "You need fish 2.2.0 or higher to use fisherman." echo "You need fish 2.2.0 or higher to use fisherman."
@ -137,10 +122,10 @@ function $fisher_cmd_name -d "fish plugin manager"
command mkdir -p {"$fish_path","$fish_config"}/{conf.d,functions,completions} "$fisher_config" "$fisher_cache" command mkdir -p {"$fish_path","$fish_config"}/{conf.d,functions,completions} "$fisher_config" "$fisher_cache"
or return 1 or return 1
set -l completions "$fish_path/completions/$fisher_cmd_name.fish" set -l completions "$fish_path/completions/fisher.fish"
if test ! -e "$completions" if test ! -e "$completions"
echo "$fisher_cmd_name --complete" > "$completions" echo "fisher --complete" > "$completions"
__fisher_complete __fisher_complete
end end
@ -206,7 +191,7 @@ function $fisher_cmd_name -d "fish plugin manager"
return return
case -\*\? case -\*\?
printf "$fisher_cmd_name: '%s' is not a valid option\n" "$argv[1]" >&2 printf "fisher: '%s' is not a valid option\n" "$argv[1]" >&2
__fisher_usage >&2 __fisher_usage >&2
return 1 return 1
@ -234,7 +219,7 @@ function $fisher_cmd_name -d "fish plugin manager"
" >&2 " >&2
__fisher_log info " __fisher_log info "
See &$fisher_cmd_name help& for usage instructions. See &fisher help& for usage instructions.
" >&2 " >&2
return return
end end
@ -393,7 +378,7 @@ function $fisher_cmd_name -d "fish plugin manager"
end end
end end
complete -c $fisher_cmd_name --erase complete -c fisher --erase
__fisher_complete __fisher_complete
end end
@ -690,11 +675,11 @@ end
function __fisher_self_update function __fisher_self_update
set -l file (status --current-filename) set -l file (status --current-filename)
if test "$file" != "$fish_path/functions/$fisher_cmd_name.fish" if test "$file" != "$fish_path/functions/fisher.fish"
return 1 return 1
end end
set -l completions "$fish_path/completions/$fisher_cmd_name.fish" set -l completions "$fish_path/completions/fisher.fish"
set -l raw_url "https://raw.githubusercontent.com/fisherman/fisherman/master/fisher.fish" set -l raw_url "https://raw.githubusercontent.com/fisherman/fisherman/master/fisher.fish"
set -l fake_qs (date "+%s") set -l fake_qs (date "+%s")
@ -710,11 +695,11 @@ function __fisher_self_update
builtin source "$file" 2> /dev/null builtin source "$file" 2> /dev/null
echo "$fisher_cmd_name -v" | source > /dev/null echo "fisher -v" | source > /dev/null
set -l new_version "$fisher_version" set -l new_version "$fisher_version"
echo "$fisher_cmd_name --complete" > "$completions" echo "fisher --complete" > "$completions"
builtin source "$completions" 2> /dev/null builtin source "$completions" 2> /dev/null
if test "$previous_version" = "$fisher_version" if test "$previous_version" = "$fisher_version"
@ -1006,7 +991,7 @@ function __fisher_get_plugin_name_from_gist -a url
set -l gist_id (printf "%s\n" "$url" | command sed 's|.*/||') set -l gist_id (printf "%s\n" "$url" | command sed 's|.*/||')
set -l name (fish -c " set -l name (fish -c "
$fisher_cmd_name -v > /dev/null fisher -v > /dev/null
curl -Ss https://api.github.com/gists/$gist_id & curl -Ss https://api.github.com/gists/$gist_id &
__fisher_jobs_await (__fisher_jobs_get -l) __fisher_jobs_await (__fisher_jobs_get -l)
@ -1743,7 +1728,7 @@ function __fisher_plugin_get_missing
if test "$name" = fisherman if test "$name" = fisherman
__fisher_log info " __fisher_log info "
Run &$fisher_cmd_name update& to update fisherman. Run &fisher update& to update fisherman.
" >&2 " >&2
continue continue
end end
@ -1954,26 +1939,26 @@ end
function __fisher_complete function __fisher_complete
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a install -d "Install plugins" complete -xc fisher -n "__fish_use_subcommand" -a install -d "Install plugins"
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a update -d "Update plugins and self" complete -xc fisher -n "__fish_use_subcommand" -a update -d "Update plugins and self"
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a rm -d "Remove plugins" complete -xc fisher -n "__fish_use_subcommand" -a rm -d "Remove plugins"
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a ls -d "List what you've installed" complete -xc fisher -n "__fish_use_subcommand" -a ls -d "List what you've installed"
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a ls-remote -d "List everything that's available" complete -xc fisher -n "__fish_use_subcommand" -a ls-remote -d "List everything that's available"
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a help -d "Show help" complete -xc fisher -n "__fish_use_subcommand" -a help -d "Show help"
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -s h -l help -d "Show usage help" complete -xc fisher -n "__fish_use_subcommand" -s h -l help -d "Show usage help"
complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -s v -l version -d "Show version information" complete -xc fisher -n "__fish_use_subcommand" -s v -l version -d "Show version information"
complete -xc $fisher_cmd_name -s q -l quiet -d "Enable quiet mode" complete -xc fisher -s q -l quiet -d "Enable quiet mode"
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from ls-remote" -l "format" -d "Format with verbs: %name, %url, %info and %stars" complete -xc fisher -n "__fish_seen_subcommand_from ls-remote" -l "format" -d "Format with verbs: %name, %url, %info and %stars"
set -l config_glob "$fisher_config"/* set -l config_glob "$fisher_config"/*
set -l config (printf "%s\n" $config_glob | command sed "s|.*/||") set -l config (printf "%s\n" $config_glob | command sed "s|.*/||")
if test ! -s "$fisher_cache/.index" if test ! -s "$fisher_cache/.index"
if test ! -z "$config" if test ! -z "$config"
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$config" complete -xc fisher -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$config"
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$fisher_active_prompt" -d "Prompt" complete -xc fisher -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$fisher_active_prompt" -d "Prompt"
end end
return return
end end
@ -1984,7 +1969,7 @@ function __fisher_complete
set -l path (command readlink "$name") set -l path (command readlink "$name")
set -l name (command basename "$name" | sed "s|$real_home|~|") set -l name (command basename "$name" | sed "s|$real_home|~|")
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$path" complete -xc fisher -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$path"
end end
set -l IFS \t set -l IFS \t
@ -2002,12 +1987,12 @@ function __fisher_complete
continue continue
end end
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from info ls-remote" -a "$name" -d "$info" complete -xc fisher -n "__fish_seen_subcommand_from info ls-remote" -a "$name" -d "$info"
if contains -- "$name" $config if contains -- "$name" $config
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$info" complete -xc fisher -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$info"
else else
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from i in install" -a "$name" -d "$info" complete -xc fisher -n "__fish_seen_subcommand_from i in install" -a "$name" -d "$info"
end end
end end
@ -2017,7 +2002,7 @@ function __fisher_complete
case fisherman\* case fisherman\*
case \* case \*
set -l name (__fisher_plugin_get_names "$i")[1] set -l name (__fisher_plugin_get_names "$i")[1]
complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$i" complete -xc fisher -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$i"
end end
end end
end end
@ -2115,7 +2100,7 @@ function __fisher_usage
set -l u (set_color -u) set -l u (set_color -u)
set -l nc (set_color normal) set -l nc (set_color normal)
echo "Usage: $fisher_cmd_name [COMMAND] [PLUGINS]" echo "Usage: fisher [COMMAND] [PLUGINS]"
echo echo
echo "where COMMAND is one of:" echo "where COMMAND is one of:"
echo " "$u"i"$nc"nstall (default)" echo " "$u"i"$nc"nstall (default)"
@ -2134,7 +2119,7 @@ end
function __fisher_help -a cmd number function __fisher_help -a cmd number
if test -z "$argv" if test -z "$argv"
set -l page "$fisher_cache/$fisher_cmd_name.1" set -l page "$fisher_cache/fisher.1"
if test ! -s "$page" if test ! -s "$page"
__fisher_man_page_write > "$page" __fisher_man_page_write > "$page"
@ -2196,8 +2181,8 @@ function __fisher_self_uninstall -a yn
$fisher_cache $fisher_cache
$fisher_config $fisher_config
$fish_config/functions/$fisher_cmd_name.fish $fish_config/functions/fisher.fish
$fish_config/completions/$fisher_cmd_name.fish $fish_config/completions/fisher.fish
" >&2 " >&2
@ -2218,16 +2203,16 @@ function __fisher_self_uninstall -a yn
end end
end end
complete -c $fisher_cmd_name --erase complete -c fisher --erase
__fisher_show_spinner __fisher_show_spinner
echo "$fisher_cmd_name ls | $fisher_cmd_name rm -q" | source 2> /dev/null echo "fisher ls | fisher rm -q" | source 2> /dev/null
__fisher_show_spinner __fisher_show_spinner
command rm -rf "$fisher_cache" "$fisher_config" command rm -rf "$fisher_cache" "$fisher_config"
command rm -f "$fish_config"/{functions,completions}/$fisher_cmd_name.fish "$fisher_file" command rm -f "$fish_config"/{functions,completions}/fisher.fish "$fisher_file"
set -e fish_config set -e fish_config
set -e fish_path set -e fish_path
@ -2242,7 +2227,7 @@ function __fisher_self_uninstall -a yn
set -l funcs (functions -a | command grep __fisher) set -l funcs (functions -a | command grep __fisher)
functions -e $funcs $fisher_cmd_name functions -e $funcs fisher
end end
@ -2254,7 +2239,7 @@ function __fisher_man_page_write
\fBfisherman\fR \- fish plugin manager \fBfisherman\fR \- fish plugin manager
. .
.SH "SYNOPSIS" .SH "SYNOPSIS"
'"$fisher_cmd_name"' [(\fBi\fRnstall | \fBu\fRpdate | \fBl\fRs[\-remote] | \fBr\fRm | \fBh\fRelp) PLUGINS] '"fisher"' [(\fBi\fRnstall | \fBu\fRpdate | \fBl\fRs[\-remote] | \fBr\fRm | \fBh\fRelp) PLUGINS]
. .
.br .br
. .
@ -2281,7 +2266,7 @@ Install a plugin\.
. .
.nf .nf
'"$fisher_cmd_name"' mono '"fisher"' mono
. .
.fi .fi
. .
@ -2294,7 +2279,7 @@ Install some plugins\.
. .
.nf .nf
'"$fisher_cmd_name"' z fzf edc/bass omf/tab '"fisher"' z fzf edc/bass omf/tab
. .
.fi .fi
. .
@ -2307,7 +2292,7 @@ Install a specific branch\.
. .
.nf .nf
'"$fisher_cmd_name"' edc/bass:master '"fisher"' edc/bass:master
. .
.fi .fi
. .
@ -2320,7 +2305,7 @@ Install a specific tag\.
. .
.nf .nf
'"$fisher_cmd_name"' done@1.2.0 '"fisher"' done@1.2.0
. .
.fi .fi
. .
@ -2333,7 +2318,7 @@ Install a gist\.
. .
.nf .nf
'"$fisher_cmd_name"' https://gist\.github\.com/username/1f40e1c6e0551b2666b2 '"fisher"' https://gist\.github\.com/username/1f40e1c6e0551b2666b2
. .
.fi .fi
. .
@ -2346,21 +2331,21 @@ Install a local directory\.
. .
.nf .nf
'"$fisher_cmd_name"' ~/my/plugin '"fisher"' ~/my/plugin
. .
.fi .fi
. .
.IP "" 0 .IP "" 0
. .
.P .P
Edit your \fIfishfile\fR and run \fB'"$fisher_cmd_name"'\fR to commit changes\. Edit your \fIfishfile\fR and run \fB'"fisher"'\fR to commit changes\.
. .
.IP "" 4 .IP "" 4
. .
.nf .nf
$EDITOR ~/\.config/fish/fishfile $EDITOR ~/\.config/fish/fishfile
'"$fisher_cmd_name"' '"fisher"'
. .
.fi .fi
. .
@ -2373,7 +2358,7 @@ Show everything you\'ve installed\.
. .
.nf .nf
'"$fisher_cmd_name"' ls '"fisher"' ls
@ plugin # a local directory @ plugin # a local directory
* mono # the current prompt * mono # the current prompt
bass bass
@ -2392,7 +2377,7 @@ Show everything that\'s available\.
. .
.nf .nf
'"$fisher_cmd_name"' ls\-remote '"fisher"' ls\-remote
. .
.fi .fi
. .
@ -2405,7 +2390,7 @@ Update everything\.
. .
.nf .nf
'"$fisher_cmd_name"' up '"fisher"' up
. .
.fi .fi
. .
@ -2418,7 +2403,7 @@ Update some plugins\.
. .
.nf .nf
'"$fisher_cmd_name"' up bass z fzf '"fisher"' up bass z fzf
. .
.fi .fi
. .
@ -2431,7 +2416,7 @@ Remove plugins\.
. .
.nf .nf
'"$fisher_cmd_name"' rm thefuck '"fisher"' rm thefuck
. .
.fi .fi
. .
@ -2444,7 +2429,7 @@ Remove all the plugins\.
. .
.nf .nf
'"$fisher_cmd_name"' ls | '"$fisher_cmd_name"' rm '"fisher"' ls | '"fisher"' rm
. .
.fi .fi
. .
@ -2457,7 +2442,7 @@ Get help\.
. .
.nf .nf
'"$fisher_cmd_name"' help z '"fisher"' help z
. .
.fi .fi
. .