Skip to content

Commit

Permalink
cli tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
fqjony committed Feb 21, 2025
1 parent a964d42 commit 6d9d0e9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 10 additions & 5 deletions lib/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/process_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ 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

log_info "Process Manager" "Starting process manager..."

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

Expand Down

0 comments on commit 6d9d0e9

Please sign in to comment.