A Bash framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

#!/bin/bash
source src/g.bash
shopt -s expand_aliases
g::log::setLevel internal
g::log::enableTarget g::arg
g::info "Defining application..."
g::app ex "A simple example application"
g::app::command shell "Start an interactive shell"
g::app::command::arg name "The name of the shell"
g::app::command::flag no-tty "Disable TTY output"
function app::ex::shell() {
echo "Starting shell: '$*'"
}
g::app::command ls "List contents of the directory"
g::app::command::flag dir= "The directory to list"
g::app::command::flag fubar= "A fubar"
g::app::command::flag dry-run "Run dry"
g::app::command::arg name "Name of the ls"
function app::ex::ls() {
local args="$1"
g::lock::try
# alias
# echo "Argcall: $args::arg"
# echo "Arg1: $($args::arg name)"
#
# echo "Arg1: $(g::arg $g__APP_LAST_ARGPARSE 0)"
# echo "Arg2: $(g::arg $g__APP_LAST_ARGPARSE name)"
#
# echo "Dir: $(g::flag $g__APP_LAST_ARGPARSE dir)"
# echo "Fubar: $(g::flag $g__APP_LAST_ARGPARSE fubar)"
# echo "dry-run: $(g::flag $g__APP_LAST_ARGPARSE dry-run)"
#
# if g::arg::has $g__APP_LAST_ARGPARSE 0; then
# echo "Has arg0"
# fi
#
# echo "All args: $(g::args $g__APP_LAST_ARGPARSE)"
}
g::app::invoke "$@"