mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-22 20:33:47 +08:00
Merge pull request #502 from oh-my-fish/feature/portable-help-text
Refactor command execution and help
This commit is contained in:
commit
37748dbbe8
10
docs/cli/cd.adoc
Normal file
10
docs/cli/cd.adoc
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Change directory to root or package directory.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf cd Change to Oh My Fish root folder
|
||||||
|
omf cd <package> Change to package directory by name
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf cd
|
||||||
|
omf cd brew
|
||||||
|
omf cd l
|
16
docs/cli/channel.adoc
Normal file
16
docs/cli/channel.adoc
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
Get or change the update channel.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf channel Print the currently selected update channel
|
||||||
|
omf channel <name> Switch to the given update channel
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Two channels are available by default: the _stable_ channel provides stable
|
||||||
|
updates with the latest tagged version of Oh My Fish, and _dev_ which provides
|
||||||
|
the latest changes under development. The update channel currently set
|
||||||
|
determines what version *omf update* will upgrade to.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf channel
|
||||||
|
omf channel stable
|
||||||
|
omf channel dev
|
22
docs/cli/describe.adoc
Normal file
22
docs/cli/describe.adoc
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Show information about a package.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf describe <name>
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Looks up a package whose name matches <name>.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
Show information about the *brew* package:
|
||||||
|
|
||||||
|
omf describe brew
|
||||||
|
|
||||||
|
We get the following output:
|
||||||
|
|
||||||
|
Package: brew
|
||||||
|
Description: Oh My Fish plugin to integrate Homebrew paths into shell.
|
||||||
|
Repository: https://github.com/oh-my-fish/plugin-brew
|
||||||
|
Maintainer:
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf d*
|
4
docs/cli/destroy.adoc
Normal file
4
docs/cli/destroy.adoc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Uninstall Oh My Fish.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf destroy
|
7
docs/cli/doctor.adoc
Normal file
7
docs/cli/doctor.adoc
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Troubleshoot Oh My Fish.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf doctor
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Checks your environment and Oh My Fish install for any potential or common problems.
|
16
docs/cli/help.adoc
Normal file
16
docs/cli/help.adoc
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
Show help text about Oh My Fish.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf help [<command>]
|
||||||
|
omf <command> --help
|
||||||
|
omf <command> -h
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
If no arguments are given, the usage guide for the *omf* command will be printed to standard output.
|
||||||
|
|
||||||
|
If <command> is specified, the usage guide for <command> will be displayed. If <command> is an alias, it will be translated into the corresponding command.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
To display the text you are currently reading, you can run:
|
||||||
|
|
||||||
|
omf help help
|
23
docs/cli/install.adoc
Normal file
23
docs/cli/install.adoc
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
Install one or more packages.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf install <spec> [<spec> [...]] Install package by name or URL
|
||||||
|
omf install Install missing packages from bundle
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Installs packages identified by each <spec> given. A package can be specified either by name or by a URL.
|
||||||
|
|
||||||
|
When specifying a package by name, the package name is searched for in each package repository currently installed. The first matching package is selected and downloaded. See `omf help repositories` for more information about repositories.
|
||||||
|
|
||||||
|
When a package is specified by URL, OMF assumes the URL points to a Git repository and installs the package by cloning the repository.
|
||||||
|
|
||||||
|
When called without arguments, any packages specified in your bundle file that are missing will be installed.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf install brew
|
||||||
|
omf install https://github.com/oh-my-fish/plugin-brew
|
||||||
|
omf install brew spark
|
||||||
|
omf install
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf i*, *omf in*, *omf get*
|
14
docs/cli/list.adoc
Normal file
14
docs/cli/list.adoc
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
List installed packages.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf list [options]
|
||||||
|
|
||||||
|
== OPTIONS
|
||||||
|
-p, --plugin::
|
||||||
|
Only list plugins.
|
||||||
|
|
||||||
|
-t, --theme::
|
||||||
|
Only list themes.
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf l*, *omf ls*
|
14
docs/cli/new.adoc
Normal file
14
docs/cli/new.adoc
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Create a new package from a template.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf new (_plugin_ | _theme_) <name>
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Creates a new package skeleton under `$OMF_CONFIG` named <name>. The type of package is determined by the first argument.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf new plugin myplugin
|
||||||
|
omf new theme mytheme
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf n*
|
34
docs/cli/omf.adoc
Normal file
34
docs/cli/omf.adoc
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
Oh My Fish! - the fish shell framework
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf [options] [<command>] [arguments]
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Provides options to list, download and remove packages, update the framework, create a new package, etc.
|
||||||
|
|
||||||
|
== COMMANDS
|
||||||
|
<<cd.adoc#,**cd**>>:: Change to root or package directory.
|
||||||
|
<<channel.adoc#,**channel**>>:: Get or change the update channel.
|
||||||
|
<<describe.adoc#,**d**escribe>>:: Show information about a package.
|
||||||
|
<<destroy.adoc#,**destroy**>>:: Uninstall Oh My Fish.
|
||||||
|
<<doctor.adoc#,**doctor**>>:: Troubleshoot Oh My Fish.
|
||||||
|
<<help.adoc#,**help**>>:: Shows help about a command.
|
||||||
|
<<install.adoc#,**i**nstall>>:: Install one or more packages.
|
||||||
|
<<list.adoc#,**l**ist>>:: List installed packages.
|
||||||
|
<<new.adoc#,**n**ew>>:: Create a new package from a template.
|
||||||
|
<<reload.adoc#,**reload**>>:: Reload the current shell.
|
||||||
|
<<remove.adoc#,**r**emove>>:: Remove a package.
|
||||||
|
<<repositories.adoc#,**repo**sitories>>:: Manage package repositories.
|
||||||
|
<<search.adoc#,**s**earch>>:: Search for a package or theme.
|
||||||
|
<<theme.adoc#,**t**heme>>:: Install and list themes.
|
||||||
|
<<update.adoc#,**u**pdate>>:: Update Oh My Fish.
|
||||||
|
<<version.adoc#,**version**>>:: Display version and exit.
|
||||||
|
|
||||||
|
== OPTIONS
|
||||||
|
-h, --help::
|
||||||
|
Display this help.
|
||||||
|
|
||||||
|
-v, --version::
|
||||||
|
Display version and exit.
|
||||||
|
|
||||||
|
For more information visit → https://git.io/oh-my-fish
|
9
docs/cli/reload.adoc
Normal file
9
docs/cli/reload.adoc
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Reload the current shell.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf reload
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Reload Oh My Fish and all plugins by using `exec` to replace current shell process with a brand new process.
|
||||||
|
|
||||||
|
This command tries to be as safe as possible, mitigating side-effects caused by exec and preventing the reload in case of background processes.
|
14
docs/cli/remove.adoc
Normal file
14
docs/cli/remove.adoc
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Remove a package.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf remove <package>
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Removes an installed package identified by <package>.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf remove brew
|
||||||
|
omf remove l
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf r*, *omf rm*, *omf uninstall*
|
29
docs/cli/repositories.adoc
Normal file
29
docs/cli/repositories.adoc
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
Manage user-installed package repositories.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf repositories [list | ls]
|
||||||
|
omf repositories add <url> [<branch>]
|
||||||
|
omf repositories (rm | remove) <url> [<branch>]
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Provides commands for viewing and managing package repositories for the current user.
|
||||||
|
|
||||||
|
Package repositories are where named packages come from used by commands like `omf install`. By default the official repository is always installed and available.
|
||||||
|
|
||||||
|
== SUBCOMMANDS
|
||||||
|
list, ls::
|
||||||
|
List installed repositories.
|
||||||
|
|
||||||
|
add::
|
||||||
|
Add a package repository located at <url>. If <branch> is not specified, the default branch of `master` is assumed.
|
||||||
|
|
||||||
|
remove, rm::
|
||||||
|
Remove a package repository.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf repositories
|
||||||
|
omf repositories add https://github.com/vendor/fish-packages
|
||||||
|
omf repositories rm https://github.com/vendor/fish-packages master
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf repo*
|
22
docs/cli/search.adoc
Normal file
22
docs/cli/search.adoc
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Search for a plugin or theme.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf search [options] <pattern>
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Search all installed package repositories for plugins and themes whose name or description matches the regular expression <pattern>. Patterns use the POSIX ERE syntax.
|
||||||
|
|
||||||
|
== OPTIONS
|
||||||
|
-p, --plugin::
|
||||||
|
Limit results to plugins.
|
||||||
|
|
||||||
|
-t, --theme::
|
||||||
|
Limit results to themes.
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf search -p nvm
|
||||||
|
omf search -t bobthefish
|
||||||
|
omf search '^gi.*$'
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf s*
|
12
docs/cli/theme.adoc
Normal file
12
docs/cli/theme.adoc
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
Install and list themes.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf theme List available themes to install
|
||||||
|
omf theme <name> Install theme by name
|
||||||
|
|
||||||
|
== EXAMPLES
|
||||||
|
omf theme
|
||||||
|
omf theme l
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf t*
|
18
docs/cli/update.adoc
Normal file
18
docs/cli/update.adoc
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
Update Oh My Fish and packages.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf update [<package1> [<package2> [...]]]
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
Updates Oh My Fish, package repositories, and installed packages.
|
||||||
|
|
||||||
|
Each package name that is given will be updated. For example, to update the packages `bobthefish` and `direnv`, run:
|
||||||
|
|
||||||
|
omf update bobthefish direnv
|
||||||
|
|
||||||
|
The special package name `omf` will cause Oh My Fish to update itself. This can be combined with other package names.
|
||||||
|
|
||||||
|
If no arguments are given, all installed packages will be updated along with Oh My Fish.
|
||||||
|
|
||||||
|
== ALIASES
|
||||||
|
*omf u*, *omf up*
|
5
docs/cli/version.adoc
Normal file
5
docs/cli/version.adoc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Display version and exit.
|
||||||
|
|
||||||
|
== USAGE
|
||||||
|
omf version
|
||||||
|
omf --version
|
|
@ -27,22 +27,24 @@ end
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from d desc describe" -a (printf "%s " (omf.index.query --type=plugin))
|
complete -c omf -f -n "__fish_seen_subcommand_from d desc describe" -a (printf "%s " (omf.index.query --type=plugin))
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from t theme" -a "$installed_themes"
|
complete -c omf -f -n "__fish_seen_subcommand_from t theme" -a "$installed_themes"
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from channel" -a "stable dev"
|
complete -c omf -f -n "__fish_seen_subcommand_from channel" -a "stable dev"
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from help" -a "install theme remove update list describe cd new destroy doctor repositories"
|
complete -c omf -f -n "__fish_seen_subcommand_from help" -a "cd channel describe destroy doctor help install get list ls new reload remove uninstall repo repositories search theme update version"
|
||||||
|
|
||||||
complete -c omf -f -a list -n "__fish_use_subcommand" -d "List local packages"
|
|
||||||
complete -c omf -f -a describe -n "__fish_use_subcommand" -d "Get information about what packages do"
|
|
||||||
complete -c omf -f -a install -n "__fish_use_subcommand" -d "Install one or more packages"
|
|
||||||
complete -c omf -f -a theme -n "__fish_use_subcommand" -d "List / Use themes"
|
|
||||||
complete -c omf -f -a remove -n "__fish_use_subcommand" -d "Remove a theme or package"
|
|
||||||
complete -c omf -f -a update -n "__fish_use_subcommand" -d "Update Oh My Fish"
|
|
||||||
complete -c omf -f -a repositories -n "__fish_use_subcommand" -d "Manage package repositories"
|
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from repo repositories; and __omf_assert_args_count 1" -a list -d "List installed repositories"
|
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from repo repositories; and __omf_assert_args_count 1" -a add -d "Add a package repository"
|
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from repo repositories; and __omf_assert_args_count 1" -a remove -d "Remove a package repository"
|
|
||||||
complete -c omf -f -a cd -n "__fish_use_subcommand" -d "Change directory to plugin/theme directory"
|
complete -c omf -f -a cd -n "__fish_use_subcommand" -d "Change directory to plugin/theme directory"
|
||||||
complete -c omf -f -a new -n "__fish_use_subcommand" -d "Create a new package from a template"
|
complete -c omf -f -a channel -n "__fish_use_subcommand" -d "Gets or changes the update channel"
|
||||||
complete -c omf -f -a search -n "__fish_use_subcommand" -d "Search the database for a theme, package or both"
|
complete -c omf -f -a describe -n "__fish_use_subcommand" -d "Get information about what packages do"
|
||||||
complete -c omf -f -a help -n "__fish_use_subcommand" -d "Display this help"
|
|
||||||
complete -c omf -f -a destroy -n "__fish_use_subcommand" -d "Remove Oh My Fish"
|
complete -c omf -f -a destroy -n "__fish_use_subcommand" -d "Remove Oh My Fish"
|
||||||
complete -c omf -f -a doctor -n "__fish_use_subcommand" -d "Troubleshoot Oh My Fish"
|
complete -c omf -f -a doctor -n "__fish_use_subcommand" -d "Troubleshoot Oh My Fish"
|
||||||
complete -c omf -f -a channel -n "__fish_use_subcommand" -d "Gets or changes the update channel"
|
complete -c omf -f -a help -n "__fish_use_subcommand" -d "Display this help"
|
||||||
|
complete -c omf -f -a install -n "__fish_use_subcommand" -d "Install one or more packages"
|
||||||
|
complete -c omf -f -a list -n "__fish_use_subcommand" -d "List local packages"
|
||||||
|
complete -c omf -f -a new -n "__fish_use_subcommand" -d "Create a new package from a template"
|
||||||
|
complete -c omf -f -a reload -n "__fish_use_subcommand" -d "Reload the current shell"
|
||||||
|
complete -c omf -f -a remove -n "__fish_use_subcommand" -d "Remove a theme or package"
|
||||||
|
complete -c omf -f -a repositories -n "__fish_use_subcommand" -d "Manage package repositories"
|
||||||
|
complete -c omf -f -n "__fish_seen_subcommand_from repo repositories; and __omf_assert_args_count 1" -a add -d "Add a package repository"
|
||||||
|
complete -c omf -f -n "__fish_seen_subcommand_from repo repositories; and __omf_assert_args_count 1" -a list -d "List installed repositories"
|
||||||
|
complete -c omf -f -n "__fish_seen_subcommand_from repo repositories; and __omf_assert_args_count 1" -a remove -d "Remove a package repository"
|
||||||
|
complete -c omf -f -a search -n "__fish_use_subcommand" -d "Search for a plugin or theme"
|
||||||
|
complete -c omf -f -a theme -n "__fish_use_subcommand" -d "Install and list themes"
|
||||||
|
complete -c omf -f -a update -n "__fish_use_subcommand" -d "Update Oh My Fish"
|
||||||
|
complete -c omf -f -a version -n "__fish_use_subcommand" -d "Display version"
|
||||||
|
|
|
@ -1,193 +1,55 @@
|
||||||
function omf.cli.help -a command
|
function omf.cli.help
|
||||||
switch "$command"
|
set -l IFS ''
|
||||||
case "c" "cd"
|
set -l doc_root $OMF_PATH/docs/cli
|
||||||
echo "\
|
set -l doc $doc_root/omf.adoc
|
||||||
Change directory to root or plugin/theme directory.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
# If a command was given, find a help document for it.
|
||||||
omf cd Change to Oh My Fish root folder
|
if set -q argv[1]
|
||||||
omf cd "(omf::em)"<package name>"(omf::off)" | "(omf::em)"<theme name>"(omf::off)" Change to plugin or theme directory by name
|
if not set command (omf.command $argv[1])
|
||||||
|
echo (omf::err)"Unknown command: $argv[1]"(omf::off) >&2
|
||||||
|
return $OMF_UNKNOWN_OPT
|
||||||
|
end
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
set doc $doc_root/$command.adoc
|
||||||
omf cd
|
|
||||||
omf cd brew
|
|
||||||
omf cd l
|
|
||||||
"
|
|
||||||
|
|
||||||
case "channel"
|
|
||||||
echo \n"\
|
|
||||||
Gets or changes the update channel.
|
|
||||||
|
|
||||||
Two channels are available by default: the "(omf::em)"stable"(omf::off)" channel provides stable
|
|
||||||
updates with the latest tagged version of Oh My Fish, and "(omf::em)"dev"(omf::off)" which provides
|
|
||||||
the latest changes under development. The update channel currently set
|
|
||||||
determines what version "(omf::em)"omf update"(omf::off)" will upgrade to.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf channel Print the currently selected update channel
|
|
||||||
omf channel "(omf::em)"<name>"(omf::off)" Switch to the given update channel
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf channel
|
|
||||||
omf channel stable
|
|
||||||
omf channel dev
|
|
||||||
"
|
|
||||||
|
|
||||||
case "d" "describe"
|
|
||||||
echo "\
|
|
||||||
Get information about what packages do.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf describe "(omf::em)"<name>"(omf::off)" Show information about a package
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf describe brew
|
|
||||||
"
|
|
||||||
|
|
||||||
case "destroy"
|
|
||||||
echo "\
|
|
||||||
Uninstall Oh My Fish.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf destroy
|
|
||||||
"
|
|
||||||
|
|
||||||
case "doctor"
|
|
||||||
echo "\
|
|
||||||
Troubleshoot Oh My Fish.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf doctor
|
|
||||||
"
|
|
||||||
|
|
||||||
case "i" "install" "get"
|
|
||||||
echo "\
|
|
||||||
Install packages.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf install Install missing packages from bundle
|
|
||||||
omf install "(omf::em)"<name>"(omf::off)" | "(omf::em)"<url>"(omf::off)" Install package by name or URL
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf install
|
|
||||||
omf install brew
|
|
||||||
omf install https://github.com/oh-my-fish/plugin-brew
|
|
||||||
"
|
|
||||||
|
|
||||||
case "l" "ls" "list"
|
|
||||||
echo "\
|
|
||||||
List local packages.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf list [ --available | -a ]
|
|
||||||
omf list [ --installed | -i ]
|
|
||||||
omf list [ --database | -d ]
|
|
||||||
"
|
|
||||||
|
|
||||||
case "n" "new"
|
|
||||||
echo "\
|
|
||||||
Create a new package from a template.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf new ("(omf::dim)"pkg"(omf::off)" | "(omf::dim)"theme"(omf::off)") "(omf::em)"<name>"(omf::off)" Create a new package from a template
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf new pkg mypkg
|
|
||||||
omf new theme mytheme
|
|
||||||
"
|
|
||||||
|
|
||||||
case "repo" "repositories"
|
|
||||||
echo "\
|
|
||||||
Manage package repositories.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf repositories [list|ls] List installed repositories
|
|
||||||
omf repositories add "(omf::em)"<url>"(omf::off)" ["(omf::em)"<branch>"(omf::off)"] Add a package repository
|
|
||||||
omf repositories rm|remove "(omf::em)"<url>"(omf::off)" ["(omf::em)"<branch>"(omf::off)"] Remove a package repository
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf repositories
|
|
||||||
omf repositories add https://github.com/vendor/fish-packages
|
|
||||||
omf repositories rm https://github.com/vendor/fish-packages master
|
|
||||||
"
|
|
||||||
|
|
||||||
case "r" "rm" "remove" "uninstall"
|
|
||||||
echo "\
|
|
||||||
Remove a theme or package.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf remove "(omf::em)"<package name>"(omf::off)" | "(omf::em)"<theme name>"(omf::off)" Removes a theme or package by name
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf remove brew
|
|
||||||
omf remove l
|
|
||||||
"
|
|
||||||
|
|
||||||
case "search"
|
|
||||||
echo "\
|
|
||||||
Search for a plugin or theme.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf search ("(omf::dim)"-p/--plugin"(omf::off)" | "(omf::dim)"-t/--theme"(omf::off)") "(omf::em)"<name>"(omf::off)" Search for a plugin or theme
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf search -p nvm
|
|
||||||
omf search -t bobthefish
|
|
||||||
omf search vi
|
|
||||||
"
|
|
||||||
|
|
||||||
case "t" "theme"
|
|
||||||
echo "\
|
|
||||||
Install and list themes.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf theme List available themes to install
|
|
||||||
omf theme "(omf::em)"<name>"(omf::off)" Install theme by name
|
|
||||||
|
|
||||||
"(omf::dim)"Examples:"(omf::off)"
|
|
||||||
omf theme
|
|
||||||
omf theme l
|
|
||||||
"
|
|
||||||
|
|
||||||
case "u" "update"
|
|
||||||
echo "\
|
|
||||||
Update Oh My Fish.
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf update
|
|
||||||
"
|
|
||||||
|
|
||||||
case "*"
|
|
||||||
echo "\
|
|
||||||
\$ omf [command] [arguments]
|
|
||||||
|
|
||||||
"(omf::dim)"Usage:"(omf::off)"
|
|
||||||
omf "(omf::em)"install"(omf::off)" [<name>|<url>]
|
|
||||||
omf "(omf::em)"theme"(omf::off)" [<name>]
|
|
||||||
omf "(omf::em)"remove"(omf::off)" [<name>]
|
|
||||||
omf "(omf::em)"search"(omf::off)" [<name>]
|
|
||||||
omf "(omf::em)"update"(omf::off)"
|
|
||||||
omf "(omf::em)"help"(omf::off)" [<command>]
|
|
||||||
|
|
||||||
"(omf::dim)"Commands:"(omf::off)"
|
|
||||||
"(omf::em)"c"(omf::off)"d Change directory to plugin/theme directory.
|
|
||||||
"(omf::em)"d"(omf::off)"escribe Get information about what packages do.
|
|
||||||
"(omf::em)"destroy"(omf::off)" Uninstall Oh My Fish.
|
|
||||||
"(omf::em)"doctor"(omf::off)" Troubleshoot Oh My Fish.
|
|
||||||
"(omf::em)"help"(omf::off)" Shows help about a specific action.
|
|
||||||
"(omf::em)"i"(omf::off)"nstall Install one or more packages.
|
|
||||||
"(omf::em)"l"(omf::off)"ist List local packages.
|
|
||||||
"(omf::em)"n"(omf::off)"ew Create a new package from a template.
|
|
||||||
"(omf::em)"r"(omf::off)"emove Remove a theme or package.
|
|
||||||
"(omf::em)"repo"(omf::off)"sitories Manage package repositories.
|
|
||||||
"(omf::em)"s"(omf::off)"earch Search for a package or theme.
|
|
||||||
"(omf::em)"t"(omf::off)"heme List / Use themes.
|
|
||||||
"(omf::em)"u"(omf::off)"pdate Update Oh My Fish.
|
|
||||||
|
|
||||||
"(omf::dim)"Options:"(omf::off)"
|
|
||||||
"(omf::em)"--h"(omf::off)"elp Display this help.
|
|
||||||
"(omf::em)"--v"(omf::off)"ersion Display version.
|
|
||||||
|
|
||||||
For more information visit → "(omf::em)"git.io/oh-my-fish"(omf::off)\n
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set -l r (set_color normal ^ /dev/null)
|
||||||
|
set -l c (set_color cyan ^ /dev/null)
|
||||||
|
set -l b (set_color --bold ^ /dev/null)
|
||||||
|
set -l u (set_color --underline ^ /dev/null)
|
||||||
|
|
||||||
|
# Format the help document for the terminal.
|
||||||
|
fold -s -w 78 $doc | sed -e "
|
||||||
|
# Strip cross references.
|
||||||
|
s/<<[^,]*,\([^>]*\)>>/\1/g
|
||||||
|
|
||||||
|
# Definition lists.
|
||||||
|
s/^\([^[:space:]].*\)::\(..*\)/\1\2/g
|
||||||
|
s/^\([^[:space:]].*\)::/$b\1$r/g
|
||||||
|
|
||||||
|
# Nice bullets for unordered lists.
|
||||||
|
s/^[*-] /· /g
|
||||||
|
|
||||||
|
# Indent everything left except for headers and the first line.
|
||||||
|
2,\$ s/^[^=]/ &/
|
||||||
|
|
||||||
|
# Headers.
|
||||||
|
s/^==* \(.*\)/$b\1$r/
|
||||||
|
|
||||||
|
# Highlight bold and monospace text.
|
||||||
|
s/\*\*\([^\*]*\)\*\*/$c\1$r/g
|
||||||
|
s/\*\([^\*]*\)\*/$c\1$r/g
|
||||||
|
s/``\([^`]*\)``/$c\1$r/g
|
||||||
|
s/`\([^`]*\)`/$c\1$r/g
|
||||||
|
|
||||||
|
# Style italics as underline.
|
||||||
|
s/__\([^_]*\)__/$u\1$r/g
|
||||||
|
s/_\([^_]*\)_/$u\1$r/g
|
||||||
|
|
||||||
|
# Underline links.
|
||||||
|
s/[[:alnum:]_][[:alnum:]_]*:[^[:space:]][^[:space:]]*/$u&$r/g
|
||||||
|
|
||||||
|
# Underline variable names in angle brackets.
|
||||||
|
s/<[^>]*>/$u&$r/g
|
||||||
|
"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
function omf.cli.new
|
function omf.cli.new
|
||||||
if test (count $argv) -ne 2
|
if test (count $argv) -ne 2
|
||||||
echo (omf::err)"Package type or name missing"(omf::off) >&2
|
echo (omf::err)"Package type or name missing"(omf::off) >&2
|
||||||
echo "Usage: omf new "(omf::em)"(pkg | theme)"(omf::off)" <name>" >&2
|
|
||||||
return $OMF_MISSING_ARG
|
return $OMF_MISSING_ARG
|
||||||
end
|
end
|
||||||
omf.packages.new $argv
|
omf.packages.new $argv
|
||||||
|
|
|
@ -9,7 +9,7 @@ function omf.cli.remove -a name
|
||||||
echo (omf::em)"$name successfully removed."(omf::off)
|
echo (omf::em)"$name successfully removed."(omf::off)
|
||||||
# Opt-in flag for testing
|
# Opt-in flag for testing
|
||||||
set -q OMF_AUTO_RELOAD
|
set -q OMF_AUTO_RELOAD
|
||||||
and omf.cli.reload
|
and omf.reload
|
||||||
case 1
|
case 1
|
||||||
echo (omf::err)"$name could not be removed."(omf::off) >&2
|
echo (omf::err)"$name could not be removed."(omf::off) >&2
|
||||||
case 2
|
case 2
|
||||||
|
|
3
pkg/omf/functions/cli/omf.cli.repositories.fish
Normal file
3
pkg/omf/functions/cli/omf.cli.repositories.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function omf.cli.repositories
|
||||||
|
omf.index.repositories $argv
|
||||||
|
end
|
|
@ -1,7 +1,18 @@
|
||||||
function omf.cli.theme -a name
|
function omf.cli.theme -a name
|
||||||
switch (count $argv)
|
switch (count $argv)
|
||||||
case 0
|
case 0
|
||||||
omf.cli.themes.list
|
test -f $OMF_CONFIG/theme
|
||||||
|
and read -l theme < $OMF_CONFIG/theme
|
||||||
|
or set -l theme default
|
||||||
|
|
||||||
|
set -l regex_current "(^|[[:space:]])($theme)([[:space:]]|\$)"
|
||||||
|
set -l highlight_current s/"$regex_current"/"\1"(omf::em)"\2"(omf::off)"\3"/g
|
||||||
|
|
||||||
|
echo (omf::under)"Installed:"(omf::off)
|
||||||
|
omf.packages.list --theme | column | sed -E "$highlight_current"
|
||||||
|
echo
|
||||||
|
echo (omf::under)"Available:"(omf::off)
|
||||||
|
omf.index.query --type=theme | column
|
||||||
case 1
|
case 1
|
||||||
omf.theme.set $name
|
omf.theme.set $name
|
||||||
case '*'
|
case '*'
|
||||||
|
|
|
@ -36,6 +36,6 @@ function omf.cli.update
|
||||||
|
|
||||||
# Opt-in flag for testing
|
# Opt-in flag for testing
|
||||||
if set -q OMF_AUTO_RELOAD
|
if set -q OMF_AUTO_RELOAD
|
||||||
omf.cli.reload
|
omf.reload
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,10 +9,10 @@ function refresh -d "(deprecated) Refresh fish session by replacing current proc
|
||||||
set -q CI
|
set -q CI
|
||||||
and return 0
|
and return 0
|
||||||
|
|
||||||
type -q omf.core.reload
|
type -q omf.reload
|
||||||
and omf.core.reload
|
and omf.reload
|
||||||
|
|
||||||
# If omf.core.reload exist, current fish will be replaced via exec, so
|
# If omf.reload exist, current fish will be replaced via exec, so
|
||||||
# the code below will never be reached. When it doesn't exist, the code
|
# the code below will never be reached. When it doesn't exist, the code
|
||||||
# below, the deprecated method, will be used as fallback.
|
# below, the deprecated method, will be used as fallback.
|
||||||
|
|
||||||
|
|
38
pkg/omf/functions/core/omf.command.fish
Normal file
38
pkg/omf/functions/core/omf.command.fish
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
function omf.command -d 'Lookup OMF command by name or alias' -a name
|
||||||
|
switch "$name"
|
||||||
|
case 'cd'
|
||||||
|
echo cd
|
||||||
|
case 'channel'
|
||||||
|
echo channel
|
||||||
|
case 'd' 'describe'
|
||||||
|
echo describe
|
||||||
|
case 'destroy'
|
||||||
|
echo destroy
|
||||||
|
case 'doctor'
|
||||||
|
echo doctor
|
||||||
|
case 'help'
|
||||||
|
echo help
|
||||||
|
case 'i' 'in' 'install' 'get'
|
||||||
|
echo install
|
||||||
|
case 'l' 'ls' 'list'
|
||||||
|
echo list
|
||||||
|
case 'n' 'new'
|
||||||
|
echo new
|
||||||
|
case 'reload'
|
||||||
|
echo reload
|
||||||
|
case 'r' 'rm' 'remove' 'uninstall'
|
||||||
|
echo remove
|
||||||
|
case 'repo' 'repositories'
|
||||||
|
echo repositories
|
||||||
|
case 's' 'search'
|
||||||
|
echo search
|
||||||
|
case 't' 'theme'
|
||||||
|
echo theme
|
||||||
|
case 'u' 'up' 'update'
|
||||||
|
echo update
|
||||||
|
case 'version'
|
||||||
|
echo version
|
||||||
|
case '*'
|
||||||
|
return $OMF_UNKNOWN_OPT
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,80 +1,51 @@
|
||||||
# SYNOPSIS
|
|
||||||
# Oh My Fish! CLI
|
|
||||||
#
|
|
||||||
# OVERVIEW
|
|
||||||
# Provides options to list, download and remove packages, update
|
|
||||||
# the framework, create / submit a new package, etc.
|
|
||||||
|
|
||||||
function omf -d "Oh My Fish"
|
function omf -d "Oh My Fish"
|
||||||
|
# Parse any options before the command name.
|
||||||
|
while set -q argv[1]
|
||||||
|
switch $argv[1]
|
||||||
|
case '-h' '--help' '-\?' '/\?'
|
||||||
|
set command help
|
||||||
|
|
||||||
if test "x$argv[-1]" = "x--help" -a (count $argv) = 2
|
case '-v' '--version'
|
||||||
set command help
|
set command version
|
||||||
set arguments $argv[1]
|
|
||||||
else if test (count $argv) -ge 2
|
case '-?*'
|
||||||
set command $argv[1]
|
echo (omf::err)"Unknown option: $argv[1]"(omf::off) >&2
|
||||||
set arguments $argv[2..-1]
|
return $OMF_UNKNOWN_OPT
|
||||||
else if test (count $argv) = 1
|
|
||||||
set command $argv[1]
|
case '*'
|
||||||
set arguments
|
break
|
||||||
else
|
end
|
||||||
set command help
|
|
||||||
set arguments
|
set -e argv[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
switch "$command"
|
# Also extract a help flag from the last argument.
|
||||||
case "-v*" "--v*"
|
switch "$argv[-1]"
|
||||||
omf.cli.version
|
case '-h' '--help' '-\?' '/\?'
|
||||||
|
set command help
|
||||||
case "-h*" "--h*" "help"
|
set -e argv[-1]
|
||||||
omf.cli.help $arguments
|
|
||||||
|
|
||||||
case "c" "cd"
|
|
||||||
omf.cli.cd $arguments
|
|
||||||
|
|
||||||
case "d" "describe"
|
|
||||||
omf.cli.describe $arguments
|
|
||||||
|
|
||||||
case "destroy"
|
|
||||||
omf.cli.destroy
|
|
||||||
|
|
||||||
case "doctor"
|
|
||||||
omf.cli.doctor
|
|
||||||
|
|
||||||
case "reload"
|
|
||||||
omf.cli.reload $arguments
|
|
||||||
|
|
||||||
case "i" "install" "get"
|
|
||||||
omf.cli.install $arguments
|
|
||||||
|
|
||||||
case "l" "ls" "list"
|
|
||||||
omf.cli.list $arguments
|
|
||||||
|
|
||||||
case "n" "new"
|
|
||||||
omf.cli.new $arguments
|
|
||||||
|
|
||||||
case "r" "rm" "remove" "uninstall"
|
|
||||||
omf.cli.remove $arguments
|
|
||||||
|
|
||||||
case "t" "theme"
|
|
||||||
omf.cli.theme $arguments
|
|
||||||
|
|
||||||
case "u" "update"
|
|
||||||
omf.cli.update $arguments
|
|
||||||
|
|
||||||
case "repo" "repositories"
|
|
||||||
omf.index.repositories $arguments
|
|
||||||
|
|
||||||
case "channel"
|
|
||||||
omf.cli.channel $arguments
|
|
||||||
|
|
||||||
case "s" "search"
|
|
||||||
omf.cli.search $arguments
|
|
||||||
|
|
||||||
case "version"
|
|
||||||
omf.cli.version $arguments
|
|
||||||
|
|
||||||
case "*"
|
|
||||||
echo (omf::err)"$argv[1] option not recognized"(omf::off) >&2
|
|
||||||
return $OMF_UNKNOWN_OPT
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Extract the command name from the remaining arguments.
|
||||||
|
if not set -q command
|
||||||
|
if set -q argv[1]
|
||||||
|
set command $argv[1]
|
||||||
|
set -e argv[1]
|
||||||
|
else
|
||||||
|
set command help
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Lookup the function for the requested command.
|
||||||
|
if not set command_name (omf.command $command)
|
||||||
|
echo (omf::err)"Unknown command: $command"(omf::off) >&2
|
||||||
|
return $OMF_UNKNOWN_OPT
|
||||||
|
end
|
||||||
|
|
||||||
|
# Execute the command.
|
||||||
|
echo "function __omf_last_command --no-scope-shadowing
|
||||||
|
omf.cli.$command_name \$argv
|
||||||
|
end" | source
|
||||||
|
|
||||||
|
__omf_last_command $argv
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,7 +40,7 @@ end
|
||||||
|
|
||||||
function omf.packages.new -a option name
|
function omf.packages.new -a option name
|
||||||
switch $option
|
switch $option
|
||||||
case "p" "pkg" "pack" "packg" "package"
|
case "p" "plugin"
|
||||||
set option "pkg"
|
set option "pkg"
|
||||||
case "t" "th" "the" "thm" "theme" "themes"
|
case "t" "th" "the" "thm" "theme" "themes"
|
||||||
set option "themes"
|
set option "themes"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user