From 6d9d0e9e1abdc5a995c85ce6cf3d2d0572b5b86b Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 21 Feb 2025 11:28:50 +0300 Subject: [PATCH] cli tweaks --- lib/cli.sh | 15 ++++++++++----- lib/cli/service.sh | 2 +- lib/process_manager.sh | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/cli.sh b/lib/cli.sh index 9eb1d1a..4ebaf35 100644 --- a/lib/cli.sh +++ b/lib/cli.sh @@ -35,12 +35,17 @@ get_available_commands() { # Extract description from help function if grep -q "${name}_help()" "$module"; then - description=$(grep -A 5 "${name}_help()" "$module" | - grep -v "${name}_help()" | - grep -v "^{" | - grep -v "cat << EOF" | + # Try to find description from comment before help function + description=$(grep -B 2 "${name}_help()" "$module" | + grep "^#" | + grep -v "Show help" | head -n 1 | - sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + sed 's/^#[[:space:]]*//;s/[[:space:]]*$//') + + # If no description found, use a generic one + if [ -z "$description" ]; then + description="Manage ${name} operations" + fi commands[$name]="$description" fi fi diff --git a/lib/cli/service.sh b/lib/cli/service.sh index 5b6a2ba..8aeb919 100644 --- a/lib/cli/service.sh +++ b/lib/cli/service.sh @@ -70,7 +70,7 @@ service_handler() { if [ "$cmd" != "init" ]; then if [ ! -f "$SERVICES_CONFIG_FILE" ]; then log_warn "Service" "No services configuration found" - log_info "Service" "Run 'worker help service' for information about service configuration" + log_info "Service" "Run 'worker service' for information about service configuration" return 1 fi fi diff --git a/lib/process_manager.sh b/lib/process_manager.sh index d511e3f..96c17c3 100644 --- a/lib/process_manager.sh +++ b/lib/process_manager.sh @@ -21,7 +21,7 @@ main() { # Check if user config exists if [[ ! -f "${USER_CONFIG_PATH}" ]]; then log_info "No services configuration found at ${USER_CONFIG_PATH}." - log_info "Run 'worker help service' for information about service configuration" + log_info "Run 'worker service' for information about service configuration" exit 0 fi @@ -29,7 +29,7 @@ main() { if ! configure_and_execute_services; then log_error "Process Manager" "Failed to configure and start services" - log_info "Run 'worker help service' for information about service configuration" + log_info "Run 'worker service' for information about service configuration" exit 1 fi