Math, source files, config files, app definitions, arg parsing
This commit is contained in:
parent
7dfd4a8cd5
commit
65af602dd4
44
example.bash
44
example.bash
@ -2,16 +2,44 @@
|
||||
|
||||
source src/g.bash
|
||||
|
||||
g::log::enable file g.log
|
||||
g::log::setLevel internal
|
||||
g::log::enableTarget g::arg
|
||||
|
||||
g::info "Starting try-catch..."
|
||||
g::info "Defining application..."
|
||||
|
||||
try {
|
||||
ls -lah baddir
|
||||
} catch {
|
||||
declare local error="$?"
|
||||
g::error "Error code: $error"
|
||||
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::info "After try-catch..."
|
||||
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"
|
||||
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 "$@"
|
||||
|
1400
src/g.bash
1400
src/g.bash
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user