Skip to content

Commit

Permalink
perf(script): add list command to list all plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kamontat committed Sep 29, 2024
1 parent 9cfe83f commit e41c311
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env bash

#= example: ./scripts/dev.sh [<components>...]
#= commands:
#= - help - for get help
#= - list - for list supported components
#= options:
#= - -h | --help - for get help
#= - -l | --list - for list supported components
#= variables:
#= - $FEAT_ENABLED=debug,dryrun,prod,prompt,deploy,wait,single,test
#= by default all features is disabled:
Expand Down Expand Up @@ -70,13 +74,10 @@ main() {

## Load components from commandline parameters
for component in "$@"; do
if [[ "$component" =~ ^-h ]] || [[ "$component" =~ ^--help ]] || [[ "$component" =~ help ]]; then
## Print file header for help
grep '^#=' "$0" | sed 's/#= //'
return 0
else
components+=("$component")
fi
cmd_on_help "$component"
cmd_on_list "$component"

components+=("$component")
done

## Load default components if no commandline supply
Expand Down Expand Up @@ -111,6 +112,28 @@ main() {
core_summary "${components[@]}"
}

cmd_on_help() {
local input="$1"
if [[ "$input" =~ ^-h ]] || [[ "$input" =~ ^--help ]] || [[ "$input" =~ help ]]; then
## Print file header for help
grep '^#=' "$0" | sed 's/#= //'
exit 0
fi
}

cmd_on_list() {
local input="$1"
if [[ "$input" =~ ^-l ]] || [[ "$input" =~ ^--list ]] || [[ "$input" =~ list ]]; then
local component
echo "Components:"
for component in "${COMPONENTS[@]}"; do
printf -- '- %s\n' "$component"
done
echo
exit 0
fi
}

export _EXIT_CODE=0
export _PATH_CWD="$PWD"
export _PATH_SCP="$_PATH_CWD/scripts"
Expand Down

0 comments on commit e41c311

Please sign in to comment.