diff --git a/sh/core/code.awk b/sh/core/code.awk index 89d0816..bfdd362 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -41,9 +41,9 @@ BEGIN { RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{" re["alias"] = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END - re["binary"] = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END + RE_BINARY = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END - re["command"] = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END + RE_COMMAND = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END RE_COMMENT = RE_BEGIN "#" RE_ANY RE_END re["constant"] = RE_BEGIN RE_CONST RE_SET RE_END RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END @@ -64,7 +64,15 @@ BEGIN { { if (action == "filter") { if (match($0, re[target], m)) { - unique[m[1]] = "" + print m[1] + } + } else if (action == "binaries") { + if (match($0, RE_BINARY, m)) { + binaries[m[1]] = "" + } + } else if (action == "commands") { + if (match($0, RE_COMMAND, m)) { + print m[1] } } else if (action == "tasks") { if (match($0, RE_MODULE, m)) { @@ -112,7 +120,7 @@ BEGIN { reset() } } else if (action == "commands functions") { - if (match($0, re["command"], m)) { + if (match($0, RE_COMMAND, m)) { append(m[1]) } else if (match($0, re["function"], m)) { split(doc, array, "\n") @@ -124,7 +132,7 @@ BEGIN { reset() } } else if (action == "command function") { - if (match($0, re["command"], m)) { + if (match($0, RE_COMMAND, m)) { append(m[1]) } else if (match($0, re["function"], m)) { split(doc, array, "\n") @@ -153,7 +161,7 @@ BEGIN { if (m[1] == target) { match_alias = 1 } - } else if (match($0, re["command"], m)) { + } else if (match($0, RE_COMMAND, m)) { append("/ " m[1]) if (m[1] == target) { match_command = 1 @@ -203,9 +211,9 @@ BEGIN { } END { - if (action == "filter") { - for (item in unique) { - print item + if (action == "binaries") { + for (binary in binaries) { + print binary } } # FIXME tasks last module end diff --git a/sh/core/code.sh b/sh/core/code.sh index 6ea16c5..4c12e49 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -41,30 +41,14 @@ _rwx_code_tasks_todo="" # cache for code variables _rwx_code_variables="" -# ╭──────┬───────────╮ -# │ code │ functions │ -# ╰──────┴───────────╯ +# ╭──────┬───────╮ +# │ code │ cache │ +# ╰──────┴───────╯ -# show the cached awk script -rwx_code_awk() { - echo "${_rwx_code_awk}" -} - -# show the cached aliases -#= rca -rwx_code_aliases() { - echo "${_rwx_code_aliases}" -} - -# show the cached aliases and functions -#= rcaf -rwx_code_aliases_functions() { - echo "${_rwx_code_aliases_functions}" -} - -# show the cached binaries -rwx_code_binaries() { - echo "${_rwx_code_binaries}" +# output all cached code +rwx_code_cache() { + rwx_code_cache_main + rwx_code_cache_user } # output cached main code @@ -77,75 +61,6 @@ rwx_code_cache_user() { echo "${rwx_code_cache_user}" } -# show the cached commands -rwx_code_commands() { - echo "${_rwx_code_commands}" -} - -# show the cached commands and functions -#= rccf -rwx_code_commands_functions() { - echo "${_rwx_code_commands_functions}" -} - -# show the cached constants -#= rcc -rwx_code_constants() { - echo "${_rwx_code_constants}" -} - -# show the cached functions -#= rcf -rwx_code_functions() { - echo "${_rwx_code_functions}" -} - -# show the cached main modules -#= rcmm -rwx_code_modules_main() { - echo "${rwx_code_modules_main}" -} - -# show the cached user modules -#= rcmu -rwx_code_modules_user() { - echo "${rwx_code_modules_user}" -} - -# show the cached tasks -#= rct -rwx_code_tasks() { - echo "${_rwx_code_tasks}" -} - -# show the cached fixme tasks -#= rctf -rwx_code_tasks_fixme() { - echo "${_rwx_code_tasks_fixme}" -} - -# show the cached todo tasks -#= rctt -rwx_code_tasks_todo() { - echo "${_rwx_code_tasks_todo}" -} - -# show the cached variables -#= rcv -rwx_code_variables() { - echo "${_rwx_code_variables}" -} - -# ╭──────┬───────╮ -# │ code │ cache │ -# ╰──────┴───────╯ - -# output all cached code -rwx_code_cache() { - rwx_code_cache_main - rwx_code_cache_user -} - # ╭──────┬─────────╮ # │ code │ install │ # ╰──────┴─────────╯ @@ -189,6 +104,11 @@ export ENV=\"${rwx_main_path}\" # │ code │ parts │ # ╰──────┴───────╯ +# show the cached awk script +rwx_code_awk() { + echo "${_rwx_code_awk}" +} + # call awk for action with target rwx_code_action_target() { local action="${1}" @@ -201,6 +121,12 @@ rwx_code_action_target() { "${_rwx_code_awk}" } +# show the cached aliases +#= rca +rwx_code_aliases() { + echo "${_rwx_code_aliases}" +} + # find command function rwx_code_command_function() { local name="${1}" @@ -212,6 +138,40 @@ rwx_code_command_function() { "${_rwx_code_awk}" } +# show the cached aliases and functions +#= rcaf +rwx_code_aliases_functions() { + echo "${_rwx_code_aliases_functions}" +} + +# show the cached binaries +rwx_code_binaries() { + echo "${_rwx_code_binaries}" +} + +# show the cached commands +rwx_code_commands() { + echo "${_rwx_code_commands}" +} + +# show the cached commands and functions +#= rccf +rwx_code_commands_functions() { + echo "${_rwx_code_commands_functions}" +} + +# show the cached constants +#= rcc +rwx_code_constants() { + echo "${_rwx_code_constants}" +} + +# show the cached functions +#= rcf +rwx_code_functions() { + echo "${_rwx_code_functions}" +} + # show all the cached main modules #= rcm rwx_code_modules() { @@ -219,6 +179,42 @@ rwx_code_modules() { rwx_code_modules_user } +# show the cached main modules +#= rcmm +rwx_code_modules_main() { + echo "${rwx_code_modules_main}" +} + +# show the cached user modules +#= rcmu +rwx_code_modules_user() { + echo "${rwx_code_modules_user}" +} + +# show the cached tasks +#= rct +rwx_code_tasks() { + echo "${_rwx_code_tasks}" +} + +# show the cached fixme tasks +#= rctf +rwx_code_tasks_fixme() { + echo "${_rwx_code_tasks_fixme}" +} + +# show the cached todo tasks +#= rctt +rwx_code_tasks_todo() { + echo "${_rwx_code_tasks_todo}" +} + +# show the cached variables +#= rcv +rwx_code_variables() { + echo "${_rwx_code_variables}" +} + # ╭──────┬───────╮ # │ code │ parse │ # ╰──────┴───────╯ @@ -262,21 +258,21 @@ EOF ${_rwx_code_commands_functions} EOF # parse aliases - _rwx_code_aliases="$(rwx_code_action_target "filter" "alias" | sort)" + _rwx_code_aliases="$(rwx_code_action_target "filter" "alias")" # parse binaries - _rwx_code_binaries="$(rwx_code_action_target "filter" "binary")" + _rwx_code_binaries="$(rwx_code_parse "binaries")" # parse commands - _rwx_code_commands="$(rwx_code_action_target "filter" "command")" + _rwx_code_commands="$(rwx_code_parse "commands")" # parse constants - _rwx_code_constants="$(rwx_code_action_target "filter" "constant" | sort)" + _rwx_code_constants="$(rwx_code_action_target "filter" "constants")" # parse functions - _rwx_code_functions="$(rwx_code_action_target "filter" "function" | sort)" + _rwx_code_functions="$(rwx_code_action_target "filter" "function")" # parse tasks _rwx_code_tasks="$(rwx_code_action_target "tasks")" _rwx_code_tasks_fixme="$(rwx_code_action_target "tasks" "FIXME")" _rwx_code_tasks_todo="$(rwx_code_action_target "tasks" "TODO")" # parse variables - _rwx_code_variables="$(rwx_code_action_target "filter" "variable" | sort)" + _rwx_code_variables="$(rwx_code_action_target "filter" "variable")" } rwx_code_parse() { diff --git a/sh/main.sh b/sh/main.sh index a897809..d3f9ccf 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -71,9 +71,9 @@ rwx_main_main() { ${modules} EOF # run code module main function with found main modules - rwx_code_main "${modules}" + rwx_code_main "${modules}" "${@}" # run shell module main function - rwx_shell_main "${@}" + rwx_shell_main } # run main function