parent
6918ff603f
commit
42ebc151c3
1 changed files with 163 additions and 145 deletions
|
@ -1,5 +1,7 @@
|
|||
# code
|
||||
|
||||
# functions
|
||||
|
||||
function alias_eval(alias, name, type) {
|
||||
text = alias "() { "
|
||||
if (type == "function") {
|
||||
|
@ -62,7 +64,10 @@ function trim(string) {
|
|||
return text
|
||||
}
|
||||
|
||||
# begin
|
||||
|
||||
BEGIN {
|
||||
|
||||
RE_ANY = "(.*)"
|
||||
RE_BEGIN = "^"
|
||||
RE_CONST = "([_A-Z][_0-9A-Z]*)"
|
||||
|
@ -95,13 +100,18 @@ BEGIN {
|
|||
match_module = 0
|
||||
match_task = 0
|
||||
reset()
|
||||
|
||||
}
|
||||
|
||||
# main
|
||||
|
||||
{
|
||||
|
||||
if (action == "filter") {
|
||||
if (match($0, re[target])) {
|
||||
unique[extract($0, target)] = ""
|
||||
}
|
||||
|
||||
} else if (action == "tasks") {
|
||||
line++
|
||||
if (match($0, RE_MODULE)) {
|
||||
|
@ -133,6 +143,7 @@ BEGIN {
|
|||
doc = ""
|
||||
match_task = 0
|
||||
}
|
||||
|
||||
} else if (action == "eval") {
|
||||
if (match($0, re[target])) {
|
||||
append(extract($0, target))
|
||||
|
@ -145,6 +156,7 @@ BEGIN {
|
|||
} else {
|
||||
reset()
|
||||
}
|
||||
|
||||
} else if (action == "function") {
|
||||
if (match($0, re["command"])) {
|
||||
append(extract($0, "command"))
|
||||
|
@ -160,6 +172,7 @@ BEGIN {
|
|||
} else {
|
||||
reset()
|
||||
}
|
||||
|
||||
} else if (action == "doc") {
|
||||
# doc
|
||||
if (match($0, RE_SHEBANG)) {
|
||||
|
@ -226,12 +239,17 @@ BEGIN {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# end
|
||||
|
||||
END {
|
||||
|
||||
if (action == "filter") {
|
||||
for (item in unique) {
|
||||
print item
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue