Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suport for adding main commands, plugins #342

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/vcsh.1.ronn.in
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,19 @@ may even lose data.

You have been warned.

## PLUGIN SYSTEM

`@TRANSFORMED_PACKAGE_NAME@` also provides a plugin system. Similar to overlays, the recommended
locations are <$XDG_CONFIG_HOME/vcsh/plugins-available> and
<$XDG_CONFIG_HOME/vcsh/plugins-enabled>.

Plugins follow the same rules as hooks and you are free to overwrite any
and all functions.

The plugin file name will be the added `@TRANSFORMED_PACKAGE_NAME@` command.
The file should contain a function with same name as the file and
optionally a help function. The help is stubbed if not implemented.

## DETAILED HOWTO AND FURTHER READING

Manpages are often short and sometimes useless to glean best practices from.
Expand Down
17 changes: 17 additions & 0 deletions vcsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fi
: "${VCSH_REPO_D:="$XDG_CONFIG_HOME/vcsh/repo.d"}"; export VCSH_REPO_D
: "${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"}"; export VCSH_HOOK_D
: "${VCSH_OVERLAY_D:="$XDG_CONFIG_HOME/vcsh/overlays-enabled"}"; export VCSH_OVERLAY_D
: "${VCSH_PLUGIN_D:="$XDG_CONFIG_HOME/vcsh/plugins-enabled"}"; export VCSH_PLUGIN_D
: "${VCSH_BASE:="$HOME"}"; export VCSH_BASE
: "${VCSH_GITIGNORE:=exact}"; export VCSH_GITIGNORE
: "${VCSH_GITATTRIBUTES:=none}"; export VCSH_GITATTRIBUTES
Expand Down Expand Up @@ -145,6 +146,17 @@ help() {

<repo> <git command> Shortcut to run git commands directly
<repo> Shortcut to enter repository" >&2
for plugin in "$VCSH_PLUGIN_D/"*; do
[ -r "$plugin" ] || continue
(
help() {
printf " %-21s%s\n" "$(basename "$plugin")" "Plugin help not implemented"
}
# shellcheck source=/dev/null
. "$plugin"
help
) >&2
done
}
# editorconfig-checker-enable

Expand Down Expand Up @@ -699,6 +711,11 @@ elif [ x"$VCSH_COMMAND" = x'status' ]; then
shift
fi
VCSH_REPO_NAME=$2; export VCSH_REPO_NAME
elif [ -n "$VCSH_COMMAND" ] &&
[ -r "$VCSH_PLUGIN_D/$VCSH_COMMAND" ]; then
info "sourcing plugin '$VCSH_PLUGIN_D/$VCSH_COMMAND'"
# shellcheck source=/dev/null
. "$VCSH_PLUGIN_D/$VCSH_COMMAND"
elif [ -n "$2" ]; then
VCSH_COMMAND='run'; export VCSH_COMMAND
VCSH_REPO_NAME=$1; export VCSH_REPO_NAME
Expand Down
Loading