- core/framework/: flag.sh, hook.sh, help.sh, command.sh, mixin.sh - core/app/: wgctl-specific context.sh, json.sh - core/framework/mixins/: json_output, no_color mixins - core/core.sh: sources framework/core.sh + app/core.sh - PYTHONPATH exported in app/core.sh for lib/ module resolution - command::_load_mixins: uses _FRAMEWORK_DIR for mixin path
21 lines
No EOL
482 B
Bash
21 lines
No EOL
482 B
Bash
#!/usr/bin/env bash
|
|
# core/mixins/json_output.mixin.sh
|
|
# Adds --json flag support to any command
|
|
|
|
_COMMAND_JSON=false
|
|
|
|
function command::mixin::json_output::register() {
|
|
flag::register --json
|
|
}
|
|
|
|
function command::mixin::json_output::reset() {
|
|
_COMMAND_JSON=false
|
|
}
|
|
|
|
function command::mixin::json_output::process() {
|
|
[[ "$1" == "--json" ]] && _COMMAND_JSON=true && return 0
|
|
return 1
|
|
}
|
|
|
|
# Public accessor
|
|
function command::json() { [[ "${_COMMAND_JSON:-false}" == "true" ]]; } |