1
1
def gen_keywords [] {
2
- let cmds = ($nu . scope. commands
2
+ let cmds = (scope commands
3
3
| where is_extern == false
4
4
and is_custom == false
5
5
and category !~ deprecated
6
- and ($it.command | str contains - n ' ' )
7
- | get command
6
+ and ($it.name | str contains - n ' ' )
7
+ | get name
8
8
| str join ' |' )
9
9
10
10
let var_with_dash_or_under_regex = ' (([a-zA-Z]+[\\-_]){1,}[a-zA-Z]+\\s)'
11
11
let preamble = ' \\b('
12
12
let postamble = ' )\\b'
13
13
$' "match": "($var_with_dash_or_under_regex )|($preamble )($cmds )($postamble )",'
14
14
}
15
- $" Generating keywords(char nl )"
16
- gen_keywords
17
- char nl
18
- char nl
15
+ print $" Generating keywords(char nl )"
16
+ print ( gen_keywords )
17
+ print ( char nl )
18
+ print ( char nl )
19
19
20
20
def gen_sub_keywords [] {
21
- let sub_cmds = ($nu . scope. commands
21
+ let sub_cmds = (scope commands
22
22
| where is_extern == false
23
23
and is_custom == false
24
24
and category !~ deprecated
25
- and ($it.command | str contains ' ' )
26
- | get command )
25
+ and ($it.name | str contains ' ' )
26
+ | get name )
27
27
28
28
let preamble = ' \\b('
29
29
let postamble = ' )\\b'
30
- let cmds = (for x in $sub_cmds {
30
+ let cmds = ($sub_cmds | each {| x |
31
31
let parts = ($x | split row ' ' )
32
32
$' ($parts.0 )\\s($parts.1 )'
33
33
} | str join ' |' )
34
34
$' "match": "($preamble )($cmds )($postamble )",'
35
35
}
36
- $" Generating sub keywords(char nl )"
37
- gen_sub_keywords
38
- char nl
36
+ print $" Generating sub keywords(char nl )"
37
+ print ( gen_sub_keywords )
38
+ print ( char nl )
39
39
40
40
def gen_keywords_alphabetically [] {
41
41
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 ]
42
- let cmds = ($nu . scope. commands
42
+ let cmds = (scope commands
43
43
| where is_extern == false
44
44
and is_custom == false
45
45
and category !~ deprecated
46
- and ($it.command | str contains - n ' ' )
47
- | get command )
46
+ and ($it.name | str contains - n ' ' )
47
+ | get name )
48
48
49
49
let preamble = ' \\b('
50
50
let postamble = ' )\\b'
51
51
52
52
53
- for alpha in $alphabet {
54
- let letter_cmds = (for cmd in $cmds {
53
+ $alphabet | each {| alpha |
54
+ let letter_cmds = ($cmds | each {| cmd |
55
55
if ($cmd | str starts-with $alpha ) {
56
56
$cmd
57
57
} else {
@@ -64,25 +64,25 @@ def gen_keywords_alphabetically [] {
64
64
} | str join " \n "
65
65
}
66
66
67
- " Generating keywords alphabetically\n "
68
- gen_keywords_alphabetically
69
- char nl
67
+ print " Generating keywords alphabetically\n "
68
+ print ( gen_keywords_alphabetically )
69
+ print ( char nl )
70
70
71
71
def gen_sub_keywords_alphabetically [] {
72
72
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 ]
73
- let sub_cmds = ($nu . scope. commands
73
+ let sub_cmds = (scope commands |
74
74
| where is_extern == false
75
75
and is_custom == false
76
76
and category !~ deprecated
77
- and ($it.command | str contains ' ' )
78
- | get command )
77
+ and ($it.name | str contains ' ' )
78
+ | get name )
79
79
80
80
let preamble = ' \\b('
81
81
let postamble = ' )\\b'
82
82
83
83
84
- for alpha in $alphabet {
85
- let letter_cmds = (for cmd in $sub_cmds {
84
+ $alphabet | each {| alpha |
85
+ let letter_cmds = ($sub_cmds | each {| cmd |
86
86
if ($cmd | str starts-with $alpha ) {
87
87
let parts = ($cmd | split row ' ' )
88
88
$' ($parts.0 )\\s($parts.1 )'
@@ -96,6 +96,6 @@ def gen_sub_keywords_alphabetically [] {
96
96
} | str join " \n "
97
97
}
98
98
99
- " Generating sub keywords alphabetically\n "
100
- gen_sub_keywords_alphabetically
101
- char nl
99
+ print " Generating sub keywords alphabetically\n "
100
+ print ( gen_sub_keywords_alphabetically )
101
+ print ( char nl )
0 commit comments