From 661ade28f610329d0f879ae8f6a569841a7894a0 Mon Sep 17 00:00:00 2001 From: Igor Date: Mon, 6 May 2024 01:23:32 +0400 Subject: [PATCH] refactor(before_v0.60): fix `gen-js-ext.nu` It has already been moved but not ported from the old version - replace pipeline `for` with `each` - explicit print - port `$nu.scope` to `scope commands` --- make_release/gen-js-ext.nu | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/make_release/gen-js-ext.nu b/make_release/gen-js-ext.nu index 1c0d6ef24..b21fc3602 100644 --- a/make_release/gen-js-ext.nu +++ b/make_release/gen-js-ext.nu @@ -1,10 +1,10 @@ def gen_keywords [] { - let cmds = ($nu.scope.commands + let cmds = (scope commands | where is_extern == false and is_custom == false and category !~ deprecated - and ($it.command | str contains -n ' ') - | get command + and ($it.name | str contains -n ' ') + | get name | str join '|') let var_with_dash_or_under_regex = '(([a-zA-Z]+[\\-_]){1,}[a-zA-Z]+\\s)' @@ -12,46 +12,46 @@ def gen_keywords [] { let postamble = ')\\b' $'"match": "($var_with_dash_or_under_regex)|($preamble)($cmds)($postamble)",' } -$"Generating keywords(char nl)" -gen_keywords -char nl -char nl +print $"Generating keywords(char nl)" +print (gen_keywords) +print (char nl) +print (char nl) def gen_sub_keywords [] { - let sub_cmds = ($nu.scope.commands + let sub_cmds = (scope commands | where is_extern == false and is_custom == false and category !~ deprecated - and ($it.command | str contains ' ') - | get command) + and ($it.name | str contains ' ') + | get name) let preamble = '\\b(' let postamble = ')\\b' - let cmds = (for x in $sub_cmds { + let cmds = ($sub_cmds | each {|x| let parts = ($x | split row ' ') $'($parts.0)\\s($parts.1)' } | str join '|') $'"match": "($preamble)($cmds)($postamble)",' } -$"Generating sub keywords(char nl)" -gen_sub_keywords -char nl +print $"Generating sub keywords(char nl)" +print (gen_sub_keywords) +print (char nl) def gen_keywords_alphabetically [] { let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z] - let cmds = ($nu.scope.commands + let cmds = (scope commands | where is_extern == false and is_custom == false and category !~ deprecated - and ($it.command | str contains -n ' ') - | get command) + and ($it.name | str contains -n ' ') + | get name) let preamble = '\\b(' let postamble = ')\\b' - for alpha in $alphabet { - let letter_cmds = (for cmd in $cmds { + $alphabet | each {|alpha| + let letter_cmds = ($cmds | each {|cmd| if ($cmd | str starts-with $alpha) { $cmd } else { @@ -64,25 +64,25 @@ def gen_keywords_alphabetically [] { } | str join "\n" } -"Generating keywords alphabetically\n" -gen_keywords_alphabetically -char nl +print "Generating keywords alphabetically\n" +print (gen_keywords_alphabetically) +print (char nl) def gen_sub_keywords_alphabetically [] { let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z] - let sub_cmds = ($nu.scope.commands + let sub_cmds = (scope commands | | where is_extern == false and is_custom == false and category !~ deprecated - and ($it.command | str contains ' ') - | get command) + and ($it.name | str contains ' ') + | get name) let preamble = '\\b(' let postamble = ')\\b' - for alpha in $alphabet { - let letter_cmds = (for cmd in $sub_cmds { + $alphabet | each {|alpha| + let letter_cmds = ($sub_cmds | each {|cmd| if ($cmd | str starts-with $alpha) { let parts = ($cmd | split row ' ') $'($parts.0)\\s($parts.1)' @@ -96,6 +96,6 @@ def gen_sub_keywords_alphabetically [] { } | str join "\n" } -"Generating sub keywords alphabetically\n" -gen_sub_keywords_alphabetically -char nl \ No newline at end of file +print "Generating sub keywords alphabetically\n" +print (gen_sub_keywords_alphabetically) +print (char nl)