From c03f0792d8b1084c3728195b448f3052394a9dcb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 10 Jul 2025 22:43:25 +0200 Subject: [PATCH 1/2] tasks/simple --- sh/core/code.awk | 10 +++++++++- sh/core/code.sh | 10 ++++++++++ sh/main.sh | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 995174f..47ec9b1 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -28,6 +28,7 @@ BEGIN { RE_CONST = "([_A-Z][_0-9A-Z]*)" RE_SET = "=.*" RE_SPACE = "[[:space:]]" + RE_TSK = "(FIXME|TODO)" RE_VAR = "([_a-z][_0-9a-z]*)" RE_SPACES = RE_SPACE "*" @@ -42,8 +43,9 @@ BEGIN { RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END - RE_MODULE = RE_BEGIN "#." RE_SPACES RE_ANY RE_END + RE_MODULE = RE_BEGIN "#\\." RE_SPACES RE_ANY RE_END RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END + RE_TASK = RE_BEGIN RE_SPACES "#" RE_SPACES RE_TSK RE_ANY RE_END RE_VARIABLE = RE_BEGIN RE_VAR RE_SET RE_END f = "" @@ -74,6 +76,12 @@ BEGIN { if (match($0, RE_FUNCTION, m)) { print m[1] } + } else if (action == "tasks") { + if (match($0, RE_MODULE, m)) { + print ". " m[1] + } else if (match($0, RE_TASK, m)) { + print $0 + } } else if (action == "variables") { if (match($0, RE_VARIABLE, m)) { print m[1] diff --git a/sh/core/code.sh b/sh/core/code.sh index 356e757..91cf559 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -34,6 +34,8 @@ _rwx_code_commands_functions="" _rwx_code_constants="" # cache for code functions _rwx_code_functions="" +# cache for code tasks +_rwx_code_tasks="" # cache for code variables _rwx_code_variables="" @@ -175,6 +177,12 @@ rwx_code_modules_user() { echo "${rwx_code_modules_user}" } +# show the cached tasks +#= rct +rwx_code_tasks() { + echo "${_rwx_code_tasks}" +} + # show the cached variables #= rcv rwx_code_variables() { @@ -233,6 +241,8 @@ EOF _rwx_code_constants="$(rwx_code_parse "constants")" # parse functions _rwx_code_functions="$(rwx_code_parse "functions")" + # parse tasks + _rwx_code_tasks="$(rwx_code_parse "tasks")" # parse variables _rwx_code_variables="$(rwx_code_parse "variables")" } diff --git a/sh/main.sh b/sh/main.sh index f14f6e7..d3f9ccf 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -32,6 +32,7 @@ rwx_main_path="${rwx_main_root}/${rwx_main_file}" # │ main │ find │ # ╰──────┴──────╯ +# FIXME separate in two functions # find root directory shell modules #| find #| sed From 4dbc9d060a26e8146cb88472190a813282924ec5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 00:22:18 +0200 Subject: [PATCH 2/2] tasks/attempt --- sh/core/code.awk | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 47ec9b1..39ad890 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -40,6 +40,7 @@ BEGIN { 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_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 RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END @@ -52,6 +53,7 @@ BEGIN { match_alias = 0 match_command = 0 match_module = 0 + match_task = 0 reset() } @@ -78,9 +80,26 @@ BEGIN { } } else if (action == "tasks") { if (match($0, RE_MODULE, m)) { - print ". " m[1] + if (output_tasks) { + print "" + print output_module + print output_tasks + output_tasks = "" + } + doc = "" + match_task = 0 + output_module = ". " m[1] } else if (match($0, RE_TASK, m)) { - print $0 + match_task = 1 + append($0) + } else if (match($0, RE_COMMENT, m)) { + append($0) + } else { + if (match_task) { + output_tasks = output_tasks "\n" doc + } + doc = "" + match_task = 0 } } else if (action == "variables") { if (match($0, RE_VARIABLE, m)) {