diff options
Diffstat (limited to 'lib/main.bash')
-rw-r--r-- | lib/main.bash | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/main.bash b/lib/main.bash index 8075b59..ce41b92 100644 --- a/lib/main.bash +++ b/lib/main.bash @@ -50,7 +50,7 @@ main() { debug "$BASHTARD_NAME/main" "\$TMPDIR set to $TMPDIR" # Actually perform the subcommand - debug "$BASHTARD_NAME/main" "Running subcommand" + debug "$BASHTARD_NAME/main" "Running subcommand '$subcommand'" subcommand "$@" local subcommand_exit=$? @@ -66,6 +66,10 @@ main() { } usage() { + local playbooks + local playbook_length + local playbook_longest=0 + cat <<EOF Usage: $BASHTARD_NAME -h @@ -73,7 +77,7 @@ Usage: $BASHTARD_NAME bootstrap $BASHTARD_NAME del <playbook> $BASHTARD_NAME ssh <command> - $BASHTARD_NAME sync + $BASHTARD_NAME sync [playbook] $BASHTARD_NAME sysinfo Perform maintenance on your infra. @@ -89,6 +93,32 @@ Commands: Playbooks: EOF + + # Find all playbooks + mapfile -t playbooks < <(find \ + "$BASHTARD_ETCDIR/playbooks.d"/* \ + -maxdepth 0 \ + -type d \ + ) + + # Find longest playbook name + for playbook in "${playbooks[@]}" + do + playbook_length="$(printf "%s" "$(basename "$playbook")" | wc -c)" + + if (( playbook_longest < playbook_length )) + then + playbook_longest=$playbook_length + fi + done + + # Render playbook descriptions + for playbook in "${playbooks[@]}" + do + printf "\t%-${playbook_longest}s %s\n" \ + "$(basename "$playbook")" \ + "$(cat "$playbook/description.txt")" + done } # Discover information about the system. If any bugs are reported and you want |