Browse Source

new: better help message with charm actions listed as commands

test
Valentin Lab 6 years ago
parent
commit
79c3e5b48b
  1. 46
      bin/compose-core

46
bin/compose-core

@ -2650,6 +2650,43 @@ get_docker_compose_single_opts_list() {
echo "$opts_list" | single_opts_filter echo "$opts_list" | single_opts_filter
} }
display_commands_help() {
local charm_actions
echo
echo "${WHITE}Commands${NORMAL} (thanks to docker-compose):"
get_docker_compose_commands_help | sed -r "s/ ([a-z]+)(\s+)/ ${DARKCYAN}\1${NORMAL}\2/g"
charm_actions_help=$(get_docker_charm_action_help) || return 1
if [ "$charm_actions_help" ]; then
echo
echo "${WHITE}Charm actions${NORMAL}:"
printf "%s\n" "$charm_actions_help" | \
sed -r "s/^ ([a-z0-9-]+)(\s+)([a-z0-9-]+)(\s+)/ ${DARKCYAN}\1${NORMAL}\2${DARKYELLOW}\3${NORMAL}\4/g"
fi
}
get_docker_charm_action_help() {
local services service charm relation_name target_service relation_config \
target_charm
services=($(get_compose_yml_content | shyaml keys 2>/dev/null))
for service in "${services[@]}"; do
out=$(
charm=$(get_service_charm "$service") || return 1
for action in $(charm.ls_direct_actions "$charm"); do
printf " %-28s %s\n" "$action $service" "Direct action from ${DARKPINK}$charm${NORMAL}"
done
while read-0 relation_name target_service _relation_config _tech_dep; do
target_charm=$(get_service_charm "$target_service") || return 1
for action in $(charm.ls_relation_actions "$target_charm" "$relation_name"); do
printf " %-28s %s\n" "$action $service" "Indirect action from ${DARKPINK}$target_charm${NORMAL}"
done
done < <(get_compose_relations "$service")
)
if [ "$out" ]; then
echo " for ${DARKYELLOW}$service${NORMAL}:"
printf "%s\n" "$out"
fi
done
}
display_help() { display_help() {
print_help print_help
@ -2671,9 +2708,7 @@ display_help() {
get_docker_compose_opts_help | remove_options_in_option_help_msg --version --help --verbose | get_docker_compose_opts_help | remove_options_in_option_help_msg --version --help --verbose |
filter_docker_compose_help_message filter_docker_compose_help_message
echo
echo "${WHITE}Commands${NORMAL} (thanks to docker-compose):"
get_docker_compose_commands_help | sed -r "s/ ([a-z]+)(\s+)/ ${DARKCYAN}\1${NORMAL}\2/g"
display_commands_help
} }
@ -3082,6 +3117,11 @@ charm.sanity_checks || die "Sanity checks about charm-store failed. Please corre
if [ -z "$is_docker_compose_action" -a "$action" ]; then if [ -z "$is_docker_compose_action" -a "$action" ]; then
action_service=${remainder_args[0]} action_service=${remainder_args[0]}
if [ -z "$action_service" ]; then
err "No such command or action: ${DARKCYAN}$action${NORMAL}"
display_commands_help
exit 1
fi
remainder_args=("${remainder_args[@]:1}") remainder_args=("${remainder_args[@]:1}")
if has_service_action "$action_service" "$action" >/dev/null; then if has_service_action "$action_service" "$action" >/dev/null; then
is_service_action=true is_service_action=true

Loading…
Cancel
Save