Skip to content

Commit

Permalink
Allow FUNCTIONS to be invoked from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
GrabbenD committed May 20, 2024
1 parent 745207a commit 2f74744
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ostree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function CLI_SETUP {

# Commands
if [[ ${CLI_ARG} == '--' ]]; then
case $CLI_VAL in
case ${CLI_VAL} in
'install')
ENV_CREATE_OPTS

Expand Down Expand Up @@ -340,10 +340,17 @@ function CLI_SETUP {
OSTREE_REVERT_IMAGE
;;

'help' | *)
*)
if [[ $(type -t ${CLI_VAL}) == 'function' ]]; then
ENV_CREATE_OPTS
${CLI_VAL}
fi
;;

* | 'help')
local USAGE=(
'Usage:'
' ostree.sh <command> [options]'
" ${0##*/} <command|function> [options]"
'Commands:'
' install : (Create deployment) : Partitions, formats and initializes a new OSTree repository'
' upgrade : (Update deployment) : Creates a new OSTree commit'
Expand All @@ -363,9 +370,7 @@ function CLI_SETUP {
' -q, --quiet : (install/upgrade) : Reduce verbosity'
)
printf >&1 '%s\n' "${USAGE[@]}"
;;&

*)
if [[ ${CLI_VAL} != 'help' && -n ${CLI_VAL} ]]; then
printf >&2 '\n%s\n' "${0##*/}: unrecognized command '${CLI_VAL}'"
exit 127
Expand Down

0 comments on commit 2f74744

Please sign in to comment.