diff --git a/docs/advanced-usage/plugin-management.md b/docs/advanced-usage/plugin-management.md index 3ac658310..b61ce2543 100644 --- a/docs/advanced-usage/plugin-management.md +++ b/docs/advanced-usage/plugin-management.md @@ -3,11 +3,11 @@ > New as of 0.4.0 ``` -plugin # Print active plugins plugin:disable # Disable an installed plugin (third-party only) plugin:enable # Enable a previously disabled plugin plugin:install [--core|git-url [--committish tag|branch|commit|--name custom-plugin-name]] # Optionally download git-url (with custom tag/committish) & run install trigger for active plugins (or only core ones) plugin:install-dependencies [--core] # Run install-dependencies trigger for active plugins (or only core ones) +plugin:list # Print active plugins plugin:uninstall # Uninstall a plugin (third-party only) plugin:update [name [committish]] # Optionally update named plugin from git (with custom tag/committish) & run update trigger for active plugins ``` diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 2a2134082..b8d5e1b8d 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -30,7 +30,7 @@ hello_main_cmd() { set -- $cmd $@ ## - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" local APP="$2"; @@ -58,7 +58,7 @@ hello_world_cmd() { set -- $cmd $@ ## - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" local APP="$2"; diff --git a/dokku b/dokku index 978d617f4..c663b240a 100755 --- a/dokku +++ b/dokku @@ -56,7 +56,7 @@ if [[ $(id -un) != "dokku" ]] && [[ ! $1 =~ plugin:* ]] && [[ ! $1 == "ssh-keys: exit $? fi -if [[ $(id -un) != "root" && $1 =~ ^plugin:.* ]] || [[ $(id -un) != "root" && $1 == "ssh-keys:add" ]]; then +if [[ $(id -un) != "root" && $1 =~ ^plugin:.* && $1 != "plugin:help" && $1 != "plugin:list" ]] || [[ $(id -un) != "root" && $1 == "ssh-keys:add" ]]; then dokku_log_fail "This command must be run as root" fi diff --git a/plugins/common/functions b/plugins/common/functions index 20cb21c46..86278277f 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -530,7 +530,7 @@ dokku_deploy_cmd() { source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" - [[ -z $1 ]] && dokku_log_fail "Please specify an app to deploy" + [[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on" local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") verify_app_name "$APP" plugn trigger pre-deploy "$APP" "$IMAGE_TAG" diff --git a/plugins/nginx-vhosts/subcommands/access-logs b/plugins/nginx-vhosts/subcommands/access-logs index 5b8fa8990..055d84713 100755 --- a/plugins/nginx-vhosts/subcommands/access-logs +++ b/plugins/nginx-vhosts/subcommands/access-logs @@ -7,7 +7,7 @@ source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" nginx_logs_cmd() { declare desc="display app nginx logs from command line" local cmd="$1" - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" nginx_logs "$@" } diff --git a/plugins/nginx-vhosts/subcommands/build-config b/plugins/nginx-vhosts/subcommands/build-config index 212c8ef15..74b118da2 100755 --- a/plugins/nginx-vhosts/subcommands/build-config +++ b/plugins/nginx-vhosts/subcommands/build-config @@ -7,7 +7,7 @@ source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" nginx_build_config_cmd() { declare desc="build nginx config to proxy app containers from command line" local cmd="nginx:build-config" - [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" nginx_build_config "$2" } diff --git a/plugins/nginx-vhosts/subcommands/default b/plugins/nginx-vhosts/subcommands/default index 5a4deae9b..08be1d5e9 100755 --- a/plugins/nginx-vhosts/subcommands/default +++ b/plugins/nginx-vhosts/subcommands/default @@ -2,4 +2,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions" -nginx_vhosts_help_cmd "$@" +nginx_vhosts_help_cmd "nginx:help" diff --git a/plugins/plugin/commands b/plugins/plugin/commands index a5b4dff78..7f4164239 100755 --- a/plugins/plugin/commands +++ b/plugins/plugin/commands @@ -7,7 +7,7 @@ case "$1" in help_content_func () { declare desc="return plugin plugin help content" cat<, Runs 'git gc --aggressive' against the application's repo - repo:purge-cache , Deletes the contents of the build cache stored in the repository -help_content - } - - if [[ $1 = "repo:help" ]] ; then - echo -e 'Usage: dokku repo[:COMMAND]' - echo '' - echo "Runs commands that interact with the app's repo" - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + repo_help_cmd "$@" ;; *) diff --git a/plugins/repo/internal-functions b/plugins/repo/internal-functions new file mode 100644 index 000000000..f58becc18 --- /dev/null +++ b/plugins/repo/internal-functions @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +repo_help_content_func () { + declare desc="return repo plugin help content" + cat<, Runs 'git gc --aggressive' against the application's repo + repo:purge-cache , Deletes the contents of the build cache stored in the repository +help_content +} + +repo_help_cmd() { + if [[ $1 = "repo:help" ]] ; then + echo -e 'Usage: dokku repo[:COMMAND]' + echo '' + echo "Runs commands that interact with the app's repo" + echo '' + echo 'Additional commands:' + repo_help_content_func | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + repo_help_content_func + else + cat< [/path/to/key], Add a new public key by pipe or path ssh-keys:remove , Remove SSH public key by name diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default index 20fea35c3..2260f6e62 100755 --- a/plugins/ssh-keys/subcommands/default +++ b/plugins/ssh-keys/subcommands/default @@ -2,4 +2,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions" -ssh_keys_help_cmd "$@" +ssh_keys_help_cmd "ssh-keys:help" diff --git a/plugins/storage/functions b/plugins/storage/functions index d65daeb26..1183fc57c 100755 --- a/plugins/storage/functions +++ b/plugins/storage/functions @@ -1,12 +1,13 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" storage_list_cmd() { declare desc="List all bound mounts" local cmd="storage:list" local passed_phases="deploy" - [[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list." + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$2" && local APP="$2" echo "$APP volume bind-mounts:" get_bind_mounts "$(get_phase_file_path "$passed_phases")" diff --git a/plugins/storage/subcommands/default b/plugins/storage/subcommands/default old mode 100644 new mode 100755 index 194ef7942..f37200047 --- a/plugins/storage/subcommands/default +++ b/plugins/storage/subcommands/default @@ -2,11 +2,12 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" -source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" storage_main_cmd() { declare desc="an alias for storage:list" local cmd="storage" + + dokku_log_warn "Deprecated: Please use storage:list" storage_list_cmd "$@" } diff --git a/plugins/storage/subcommands/list b/plugins/storage/subcommands/list index a16999a38..ca27076b3 100755 --- a/plugins/storage/subcommands/list +++ b/plugins/storage/subcommands/list @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" -source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" storage_list_cmd "$@" diff --git a/plugins/tar/commands b/plugins/tar/commands index 60a8123a5..50fb131fb 100755 --- a/plugins/tar/commands +++ b/plugins/tar/commands @@ -1,27 +1,11 @@ #!/usr/bin/env bash [[ " help tar:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/tar/internal-functions" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | tar:help) - help_content_func () { - declare desc="return tar plugin help content" - cat<, Reads an tarball containing the app from stdin - tar:from , Loads an app tarball from url -help_content - } - - if [[ $1 = "tar:help" ]] ; then - echo -e 'Usage: dokku tar[:COMMAND]' - echo '' - echo 'An alternative to using git, apps are loaded via tarballs instead.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, - else - help_content_func - fi + tar_help_cmd "$1" ;; *) diff --git a/plugins/tar/internal-functions b/plugins/tar/internal-functions new file mode 100644 index 000000000..1d81df165 --- /dev/null +++ b/plugins/tar/internal-functions @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +tar_help_content_func() { + declare desc="return tar plugin help content" + cat<, Reads an tarball containing the app from stdin + tar:from , Loads an app tarball from url +help_content +} + +tar_help_cmd() { + if [[ $1 = "tar:help" ]] ; then + echo -e 'Usage: dokku tar[:COMMAND]' + echo '' + echo 'An alternative to using git, apps are loaded via tarballs instead.' + echo '' + echo 'Additional commands:' + tar_help_content_func | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + tar_help_content_func + else + cat<