Skip to content

Commit

Permalink
subcommands assign and handle fixelioration
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriGilbert committed Sep 21, 2023
1 parent 698bd23 commit 36217bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 12 additions & 2 deletions bin/pos/subcmd-assign
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,21 @@ trap on_interrupt INT;
# @parseArger-parsing-end
# print_debug "$@"
# @parseArger-end

_tgtdir="";
if [ "${_arg_subcommand_directory}" != "" ];then
_tgtdir="${_arg_subcommand_directory}";
[[ $_tgtdir != */ ]] && _tgtdir+="/";
fi

echo -e "${_arg_subcommand_variable}+=(\"\$_SCRIPT_DIR/$_tgtdir\${1}\");";
echo -e "
if [ \"\$_arg_subcommand_arg\" == \"\$_positional_name\" ];then
if [ -d \"\$_SCRIPT_DIR/$_tgtdir\${1}\" ];then
${_arg_subcommand_variable}+=(\"\$_SCRIPT_DIR/$_tgtdir\${1}\");
elif [[ \"$_tgtdir\" == \$(basename \"\$_SCRIPT_DIR\")* ]];then
cmdToSub=\"\$(basename \"\$_SCRIPT_DIR\")\";
cmdsubDir=\"$_tgtdir\";
${_arg_subcommand_variable}+=(\"\$_SCRIPT_DIR\${cmdsubDir#\"\${cmdToSub}\"}\${1}\");
else
${_arg_subcommand_variable}+=(\"\$_SCRIPT_DIR/$_tgtdir\${1}\");
fi
fi";
12 changes: 7 additions & 5 deletions bin/pos/subcmd-handle
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,19 @@ trap on_interrupt INT;
# print_debug "$@"
# @parseArger-end

# TODO get script set verbose_level
outStr="if [ \"\$_triggerSCHelp\" == \"0\" ];then
outStr="";

if [ "$_arg_subcommand_use_leftovers" != "off" ]; then
outStr+="${_arg_subcommand_variable}+=(\"\${_arg_leftovers[@]}\");\n";
fi

outStr+="if [ \"\$_triggerSCHelp\" == \"0\" ];then
__subcommand+=(\"--help\");
fi
if [ \"\$_verbose_level\" -ne \"0\" ];then
__subcommand+=(\"--verbose\" \"\$_verbose_level\");
fi
";
if [ "$_arg_subcommand_use_leftovers" != "off" ]; then
outStr+="${_arg_subcommand_variable}+=(\"\${_arg_leftovers[@]}\");";
fi
if [ "$_arg_subcommand_run" != "off" ]; then
outStr+="\"\${${_arg_subcommand_variable}[@]}\";";
fi
Expand Down

0 comments on commit 36217bf

Please sign in to comment.