Closed tomeichlersmith closed 4 months ago
I'm going to close this now. After some investigation, the generated code by argc
is not posix-sh compliant and the project is not very focused on generating posix-sh compliant code and instead focused on having argc available to do the argument handling. This is a reasonable choice from my perspective, but makes it a bad fit for this project.
tom@nixos:~/code/denv/argc-investigation$ ./argc --argc-version
argc 1.17.0
tom@nixos:~/code/denv/argc-investigation$ cat denv-mimic
#!/bin/sh
# @cmd
config() {
:
}
# @cmd
init() {
:
}
tom@nixos:~/code/denv/argc-investigation$ ./argc --argc-build denv-mimic > denv-mimic-cli
tom@nixos:~/code/denv$ shellcheck argc-investigation/denv-mimic-cli > shellcheck.log
shellcheck.log
In argc-investigation/denv-mimic-cli line 18:
if [[ "$1" == "___internal___" ]]; then
^----------------------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
In argc-investigation/denv-mimic-cli line 21:
argc__args=("$(basename "$0" .sh)" "$@")
^---------------------------^ SC3030 (warning): In POSIX sh, arrays are undefined.
In argc-investigation/denv-mimic-cli line 22:
argc__positionals=()
^-- SC3030 (warning): In POSIX sh, arrays are undefined.
In argc-investigation/denv-mimic-cli line 25:
_argc_tools=()
^-- SC3030 (warning): In POSIX sh, arrays are undefined.
In argc-investigation/denv-mimic-cli line 27:
if [ -n "$argc__fn" ]; then
^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
if [ -n "${argc__fn}" ]; then
In argc-investigation/denv-mimic-cli line 28:
$argc__fn "${argc__positionals[@]}"
^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
^---------------------^ SC3054 (warning): In POSIX sh, array references are undefined.
Did you mean:
${argc__fn} "${argc__positionals[@]}"
In argc-investigation/denv-mimic-cli line 49:
local _argc_key _argc_action
^--------------------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
In argc-investigation/denv-mimic-cli line 50:
local _argc_subcmds="config, init"
^-----------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
In argc-investigation/denv-mimic-cli line 51:
while [[ $_argc_index -lt $_argc_len ]]; do
^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
while [[ ${_argc_index} -lt ${_argc_len} ]]; do
In argc-investigation/denv-mimic-cli line 52:
_argc_item="${argc__args[_argc_index]}"
^------------------------^ SC3054 (warning): In POSIX sh, array references are undefined.
In argc-investigation/denv-mimic-cli line 54:
case "$_argc_key" in
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
case "${_argc_key}" in
In argc-investigation/denv-mimic-cli line 63:
argc__positionals+=("${argc__args[@]:$((_argc_index + 1))}")
^---------------^ SC3024 (warning): In POSIX sh, += is undefined.
^-- SC3030 (warning): In POSIX sh, arrays are undefined.
In argc-investigation/denv-mimic-cli line 64:
_argc_index=$_argc_len
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
_argc_index=${_argc_len}
In argc-investigation/denv-mimic-cli line 78:
local help_arg="${argc__args[$((_argc_index + 1))]}"
^------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
^-- SC3054 (warning): In POSIX sh, array references are undefined.
In argc-investigation/denv-mimic-cli line 79:
case "$help_arg" in
^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
case "${help_arg}" in
In argc-investigation/denv-mimic-cli line 90:
_argc_die "error: invalid value \`$help_arg\` for \`<command>\`"$'\n'" [possible values: $_argc_subcmds]"
^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
^---^ SC3003 (warning): In POSIX sh, $'..' is undefined.
^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
_argc_die "error: invalid value \`${help_arg}\` for \`<command>\`"$'\n'" [possible values: ${_argc_subcmds}]"
In argc-investigation/denv-mimic-cli line 95:
_argc_die "error: \`denv-mimic\` requires a subcommand but one was not provided"$'\n'" [subcommands: $_argc_subcmds]"
^---^ SC3003 (warning): In POSIX sh, $'..' is undefined.
^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
_argc_die "error: \`denv-mimic\` requires a subcommand but one was not provided"$'\n'" [subcommands: ${_argc_subcmds}]"
In argc-investigation/denv-mimic-cli line 99:
if [[ -n "$_argc_action" ]]; then
^----------------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
if [[ -n "${_argc_action}" ]]; then
In argc-investigation/denv-mimic-cli line 100:
$_argc_action
^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
${_argc_action}
In argc-investigation/denv-mimic-cli line 114:
local _argc_key _argc_action
^--------------------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
In argc-investigation/denv-mimic-cli line 115:
local _argc_subcmds=""
^-----------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
In argc-investigation/denv-mimic-cli line 116:
while [[ $_argc_index -lt $_argc_len ]]; do
^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
while [[ ${_argc_index} -lt ${_argc_len} ]]; do
In argc-investigation/denv-mimic-cli line 117:
_argc_item="${argc__args[_argc_index]}"
^------------------------^ SC3054 (warning): In POSIX sh, array references are undefined.
In argc-investigation/denv-mimic-cli line 119:
case "$_argc_key" in
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
case "${_argc_key}" in
In argc-investigation/denv-mimic-cli line 125:
argc__positionals+=("${argc__args[@]:$((_argc_index + 1))}")
^---------------^ SC3024 (warning): In POSIX sh, += is undefined.
^-- SC3030 (warning): In POSIX sh, arrays are undefined.
In argc-investigation/denv-mimic-cli line 126:
_argc_index=$_argc_len
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
_argc_index=${_argc_len}
In argc-investigation/denv-mimic-cli line 130:
argc__positionals+=("$_argc_item")
^---------------^ SC3024 (warning): In POSIX sh, += is undefined.
^-------------^ SC3030 (warning): In POSIX sh, arrays are undefined.
^---------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
argc__positionals+=("${_argc_item}")
In argc-investigation/denv-mimic-cli line 135:
if [[ -n "$_argc_action" ]]; then
^----------------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
if [[ -n "${_argc_action}" ]]; then
In argc-investigation/denv-mimic-cli line 136:
$_argc_action
^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
${_argc_action}
In argc-investigation/denv-mimic-cli line 139:
if [[ "${argc__positionals[0]}" == "help" ]] && [[ "${#argc__positionals[@]}" -eq 1 ]]; then
^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^---------------------^ SC3054 (warning): In POSIX sh, array references are undefined.
^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.
In argc-investigation/denv-mimic-cli line 153:
local _argc_key _argc_action
^--------------------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
In argc-investigation/denv-mimic-cli line 154:
local _argc_subcmds=""
^-----------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
In argc-investigation/denv-mimic-cli line 155:
while [[ $_argc_index -lt $_argc_len ]]; do
^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
while [[ ${_argc_index} -lt ${_argc_len} ]]; do
In argc-investigation/denv-mimic-cli line 156:
_argc_item="${argc__args[_argc_index]}"
^------------------------^ SC3054 (warning): In POSIX sh, array references are undefined.
In argc-investigation/denv-mimic-cli line 158:
case "$_argc_key" in
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
case "${_argc_key}" in
In argc-investigation/denv-mimic-cli line 164:
argc__positionals+=("${argc__args[@]:$((_argc_index + 1))}")
^---------------^ SC3024 (warning): In POSIX sh, += is undefined.
^-- SC3030 (warning): In POSIX sh, arrays are undefined.
In argc-investigation/denv-mimic-cli line 165:
_argc_index=$_argc_len
^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
_argc_index=${_argc_len}
In argc-investigation/denv-mimic-cli line 169:
argc__positionals+=("$_argc_item")
^---------------^ SC3024 (warning): In POSIX sh, += is undefined.
^-------------^ SC3030 (warning): In POSIX sh, arrays are undefined.
^---------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
argc__positionals+=("${_argc_item}")
In argc-investigation/denv-mimic-cli line 174:
if [[ -n "$_argc_action" ]]; then
^----------------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
if [[ -n "${_argc_action}" ]]; then
In argc-investigation/denv-mimic-cli line 175:
$_argc_action
^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
Did you mean:
${_argc_action}
In argc-investigation/denv-mimic-cli line 178:
if [[ "${argc__positionals[0]}" == "help" ]] && [[ "${#argc__positionals[@]}" -eq 1 ]]; then
^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.
^---------------------^ SC3054 (warning): In POSIX sh, array references are undefined.
^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.
In argc-investigation/denv-mimic-cli line 185:
if [[ $# -eq 0 ]]; then
^------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
For more information:
https://www.shellcheck.net/wiki/SC3003 -- In POSIX sh, $'..' is undefined.
https://www.shellcheck.net/wiki/SC3010 -- In POSIX sh, [[ ]] is undefined.
https://www.shellcheck.net/wiki/SC3024 -- In POSIX sh, += is undefined.
https://github.com/sigoden/argc
It's mainly marketed as a way to avoid boilerplate in scripts, but it also has a "build" option which can generate the boilerplate CLI code. I want to see if we can use this because then the CLI, the help messages, and the man pages would all be generated from the same source of truth.
Checks