2015-08-26 15:20:13 +00:00
|
|
|
# SYNOPSIS
|
2015-08-28 09:02:24 +00:00
|
|
|
# Oh My Fish! CLI
|
2015-08-26 15:20:13 +00:00
|
|
|
#
|
|
|
|
# ENV
|
2015-08-28 09:02:24 +00:00
|
|
|
# OMF_CONFIG Oh My Fish! configuration
|
2015-08-26 15:20:13 +00:00
|
|
|
#
|
|
|
|
# OVERVIEW
|
|
|
|
# Provides options to list, download and remove packages, update
|
|
|
|
# the framework, create / submit a new package, etc.
|
|
|
|
|
|
|
|
set -g OMF_MISSING_ARG 1
|
|
|
|
set -g OMF_UNKNOWN_OPT 2
|
|
|
|
set -g OMF_INVALID_ARG 3
|
|
|
|
set -g OMF_UNKNOWN_ERR 4
|
|
|
|
|
2015-08-28 01:00:07 +00:00
|
|
|
function omf::em
|
2015-08-28 09:02:24 +00:00
|
|
|
set_color $fish_color_match ^/dev/null; or set_color cyan
|
2015-08-28 01:00:07 +00:00
|
|
|
end
|
2015-08-28 09:02:24 +00:00
|
|
|
|
2015-08-28 01:00:07 +00:00
|
|
|
function omf::dim
|
2015-08-28 16:46:41 +00:00
|
|
|
set_color $fish_color_autosuggestion ^/dev/null; or set_color 555
|
2015-08-28 01:00:07 +00:00
|
|
|
end
|
2015-08-28 09:02:24 +00:00
|
|
|
|
2015-08-28 01:00:07 +00:00
|
|
|
function omf::err
|
2015-08-28 09:02:24 +00:00
|
|
|
set_color $fish_color_error ^/dev/null; or set_color red --bold
|
2015-08-28 01:00:07 +00:00
|
|
|
end
|
2015-08-28 09:02:24 +00:00
|
|
|
|
2015-08-28 01:00:07 +00:00
|
|
|
function omf::off
|
|
|
|
set_color normal
|
|
|
|
end
|
2015-08-26 15:20:13 +00:00
|
|
|
|
|
|
|
function init -a path --on-event init_omf
|
|
|
|
autoload $path/cli $path/util
|
|
|
|
end
|
|
|
|
|
|
|
|
function omf -d "Oh My Fish"
|
|
|
|
if test (count $argv) -eq 0
|
2015-08-29 19:42:34 +00:00
|
|
|
omf.help "main"; and return 0
|
|
|
|
else
|
|
|
|
if test $argv[-1] = "--help" -a (count $argv) = 2
|
|
|
|
omf.help $argv[1..-2]; and return 0
|
|
|
|
end
|
2015-08-26 15:20:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
switch $argv[1]
|
2015-08-28 16:08:40 +00:00
|
|
|
case "-v*" "--v*"
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.version
|
2015-08-26 15:20:13 +00:00
|
|
|
|
|
|
|
case "q" "query"
|
|
|
|
switch (count $argv)
|
|
|
|
case 1
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.query_env
|
2015-08-26 15:20:13 +00:00
|
|
|
case 2
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.query_env "$argv[2]"
|
2015-08-26 15:20:13 +00:00
|
|
|
case "*"
|
|
|
|
echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2
|
|
|
|
echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" [<variable name>]" 1^&2
|
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
|
|
|
|
2015-08-28 16:08:40 +00:00
|
|
|
case "-h*" "--h*" "help"
|
2015-08-29 19:42:34 +00:00
|
|
|
if test (count $argv) -eq 1
|
|
|
|
omf.help "main"
|
|
|
|
else
|
|
|
|
omf.help $argv[2]
|
|
|
|
end
|
2015-08-26 15:20:13 +00:00
|
|
|
|
2015-08-28 16:10:05 +00:00
|
|
|
case "c" "cd"
|
|
|
|
switch (count $argv)
|
|
|
|
case 1
|
|
|
|
omf.cd
|
|
|
|
case 2
|
|
|
|
omf.cd $argv[2]
|
|
|
|
case "*"
|
|
|
|
echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2
|
|
|
|
echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" <name>" 1^&2
|
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
|
|
|
|
2015-08-26 15:20:13 +00:00
|
|
|
case "l" "li" "lis" "lst" "list"
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.list_local_packages | column
|
2015-08-26 15:20:13 +00:00
|
|
|
|
2015-08-29 09:35:17 +00:00
|
|
|
case "d" "desc" "describe"
|
|
|
|
if test (count $argv) -eq 1
|
|
|
|
omf.describe
|
|
|
|
else
|
|
|
|
omf.describe $argv[2..-1]
|
|
|
|
end
|
|
|
|
|
2015-08-26 19:46:16 +00:00
|
|
|
case "i" "install" "get"
|
2015-08-26 15:20:13 +00:00
|
|
|
if test (count $argv) -eq 1
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.list_db_packages | column
|
2015-08-26 15:20:13 +00:00
|
|
|
else
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.install_package $argv[2..-1]
|
2015-08-27 18:04:56 +00:00
|
|
|
refresh
|
2015-08-26 15:20:13 +00:00
|
|
|
end
|
|
|
|
|
2015-08-26 18:06:37 +00:00
|
|
|
case "t" "theme"
|
2015-08-26 15:20:13 +00:00
|
|
|
if test (count $argv) -eq 1
|
|
|
|
set -l theme (cat $OMF_CONFIG/theme)
|
|
|
|
set -l regex "[[:<:]]($theme)[[:>:]]"
|
|
|
|
test "$OSTYPE" != "Darwin"; and set regex "\b($theme)\b"
|
|
|
|
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.list_themes | column | sed -E "s/$regex/"(omf::em)"\1"(omf::off)"/"
|
2015-08-26 15:20:13 +00:00
|
|
|
omf::off
|
|
|
|
|
|
|
|
else if test (count $argv) -eq 2
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.theme $argv[2]
|
2015-08-27 18:04:56 +00:00
|
|
|
refresh
|
2015-08-26 15:20:13 +00:00
|
|
|
else
|
|
|
|
echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2
|
|
|
|
echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" [<theme name>]" 1^&2
|
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
|
|
|
|
2015-08-26 19:43:01 +00:00
|
|
|
case "r" "rem" "rm" "remove" "uninstall"
|
2015-08-26 15:20:13 +00:00
|
|
|
if test (count $argv) -ne 2
|
|
|
|
echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2
|
|
|
|
echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" <[package|theme] name>" 1^&2
|
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.remove_package $argv[2..-1]
|
2015-08-26 15:20:13 +00:00
|
|
|
|
2015-08-26 19:46:16 +00:00
|
|
|
case "u" "up" "upd" "update"
|
2015-08-26 15:20:13 +00:00
|
|
|
pushd $OMF_PATH
|
|
|
|
echo (omf::em)"Updating Oh My Fish..."(omf::off)
|
2015-08-27 18:55:29 +00:00
|
|
|
if omf.update
|
2015-08-26 15:20:13 +00:00
|
|
|
echo (omf::em)"Oh My Fish is up to date."(omf::off)
|
|
|
|
else
|
|
|
|
echo (omf::err)"Oh My Fish failed to update."(omf::off)
|
|
|
|
echo "Please open a new issue here → "(omf::em)"git.io/omf-issues"(omf::off)
|
|
|
|
end
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.theme (cat $OMF_CONFIG/theme)
|
|
|
|
omf.install_package (omf.list_installed_packages)
|
2015-08-26 15:20:13 +00:00
|
|
|
popd
|
|
|
|
refresh
|
|
|
|
|
|
|
|
case "s" "su" "sub" "submit"
|
|
|
|
switch (count $argv)
|
|
|
|
case 3
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.submit $argv[2] $argv[3]
|
2015-08-26 15:20:13 +00:00
|
|
|
case "*"
|
|
|
|
echo (omf::err)"Argument missing"(omf::off) 1^&2
|
|
|
|
echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" "(omf::em)"pkg|themes"(omf::off)"/<name> <url>" 1^&2
|
|
|
|
return $OMF_MISSING_ARG
|
|
|
|
end
|
|
|
|
|
|
|
|
case "n" "nw" "new"
|
|
|
|
if test (count $argv) -ne 3
|
|
|
|
echo (omf::err)"Package type or name missing"(omf::off) 1^&2
|
|
|
|
echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" "(omf::em)"pkg|theme"(omf::off)" <name>" 1^&2
|
|
|
|
return $OMF_MISSING_ARG
|
|
|
|
end
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.new $argv[2..-1]
|
2015-08-26 15:20:13 +00:00
|
|
|
|
|
|
|
case "destroy"
|
2015-08-27 18:55:29 +00:00
|
|
|
omf.destroy
|
2015-08-26 15:20:13 +00:00
|
|
|
|
|
|
|
case "*"
|
|
|
|
echo (omf::err)"$argv[1] option not recognized"(omf::off) 1^&2
|
|
|
|
return $OMF_UNKNOWN_OPT
|
|
|
|
end
|
|
|
|
end
|