Skip to content

Commit 4f7671f

Browse files
committed
Upgrade Goal, enhance vendored help
1 parent cbdd69b commit 4f7671f

File tree

7 files changed

+35
-23
lines changed

7 files changed

+35
-23
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22
55
toolchain go1.22.7
66

77
require (
8-
codeberg.org/anaseto/goal v1.0.0
8+
codeberg.org/anaseto/goal v1.0.1-0.20241109155047-ee95ff40957e
99
github.com/charmbracelet/lipgloss v1.0.0
1010
github.com/go-resty/resty/v2 v2.16.0
1111
github.com/jarcoal/httpmock v1.3.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
codeberg.org/anaseto/goal v1.0.0 h1:bE4KdvlQlRt/c9ktZIzIrweG6WeBN53vGbGar5wnGtQ=
2-
codeberg.org/anaseto/goal v1.0.0/go.mod h1:uSilOn+ZWioD+gG+3OopP090Fth5H47V/TU9ziI++CM=
1+
codeberg.org/anaseto/goal v1.0.1-0.20241109155047-ee95ff40957e h1:4djk1MQ/HyHGsANgbtEy9OGMUEFgFFLZ9dpHRd7yJNw=
2+
codeberg.org/anaseto/goal v1.0.1-0.20241109155047-ee95ff40957e/go.mod h1:uSilOn+ZWioD+gG+3OopP090Fth5H47V/TU9ziI++CM=
33
github.com/apache/arrow/go/v17 v17.0.0 h1:RRR2bdqKcdbss9Gxy2NS/hK8i4LDMh23L6BbkN5+F54=
44
github.com/apache/arrow/go/v17 v17.0.0/go.mod h1:jR7QHkODl15PfYyjM2nU+yTLScZ/qfj7OSUZmJ8putc=
55
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=

script/vendor-help

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ GOALSHA="$(git -C $GOAL rev-parse HEAD)"
66

77
mkdir -p "$REPO/vendored"
88
cp -R "$GOAL/help" "$REPO/vendored/"
9+
printf "\nfunc Map() map[string]string {\n return initHelp()\n}\n" >> "$REPO/vendored/help/get.go"
910
printf "# Vendored Go Code from Goal Project\n\nPulled from Goal at Git commit: \`$GOALSHA\`\n" > "$REPO/vendored/README.md"

vendor-goal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Vendored Goal Code from Goal Project
22

3-
Pulled from Goal at Git commit: `69d8c2236f559ab8c3d8ca3485beec5bf4c0346a`
3+
Pulled from Goal at Git commit: `ee95ff40957e5d75a474458fd5c8418ce2ccac16`

vendor-goal/fmt.goal

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
/ dict[d;f] outputs dict d, assuming string keys and atom or flat array values,
2-
/ using format string f for floating point numbers.
1+
/ dict[d;f] outputs dict d using format string f for floating point numbers.
32
dict:{[d;f]
43
nk:#d; say"=== Dict ($nk keys) ==="
5-
k:(|/-1+""#k)!k:!d; v:" "/(..?[(@x)¿"nN";p.f$x;$'x])'.d
6-
say"\n"/k{"$x| $y"}'v
7-
}
8-
/ tbl[t;r;c;f] outputs dict t as table, assuming string keys and flat columns,
9-
/ and outputs at most r rows and c columns, using format string f for floating
10-
/ point numbers. Example: tbl[t;5;8;"%.1f"].
4+
k:(|/-1+""#k)!k:keys@!d; v:val[f]'.d
5+
say"\n"/k{"$x| $y"}'v}
6+
/ tbl[t;r;c;f] outputs dict t as table using at most r rows and c columns, and
7+
/ format string f for floating point numbers.
8+
/ Example: tbl[t;5;8;"%.1f"].
119
tbl:{[t;r;c;f]
1210
(nr;nc):(#*t;#t); say"=== Table ${nr}x$nc ==="
13-
t:t[!r&nr;(c&nc)@!t] / keep up to r rows and c columns
14-
k:!t; v:(..?[(@x)¿"nN";p.f$x;$'x])'.t; w:(-1+""#k)|(|/-1+""#)'v
15-
(k;v):(-w)!'´(k;v); say"\n"/,/" "/(k;"-"*w;+v)
16-
}
11+
m:{?[x<0;x|-y;x&y]}; t:t[!m[r;nr];m[c;nc]@!t:![keys@!t;{1}#'.t]]
12+
k:!t; v:(..?[(@x)¿"nN";p.f$x;"A"~@x;q.val[p.f]'x;$'x])'.t; w:(-1+""#k)|(|/-1+""#)'v
13+
(k;v):(-w)!'´(k;v); say"\n"/,/" "/(k;"-"*w;+v)}
14+
/ val[f;x] formats value x using f$x for floats and $x otherwise.
15+
val:{[f;x]?[(@x)¿"nN";(" "/f$x)or"?0";"A"~@x;[x:";"/o[f]'x;"($x)"];$x]}
16+
/ keys formats list into a list of string keys (if not already one).
17+
keys:{?[(@x)¿"S";x;$'x]}
1718
1

vendored/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Vendored Go Code from Goal Project
22

3-
Pulled from Goal at Git commit: `69d8c2236f559ab8c3d8ca3485beec5bf4c0346a`
3+
Pulled from Goal at Git commit: `ee95ff40957e5d75a474458fd5c8418ce2ccac16`

vendored/help/get.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,30 @@ func initHelp() map[string]string {
6363
help["rshift"] = help["»"]
6464
help["«"] = getBuiltin(helpVerbs, "«", vcols)
6565
help["shift"] = help["«"]
66-
for _, v := range []string{"+", "-", "*", "%", "!", "&", "|", "<", ">", "=", "~", ",", "^",
67-
"#", "_", "$", "?", "@", "."} {
66+
for _, v := range []string{
67+
"+", "-", "*", "%", "!", "&", "|", "<", ">", "=", "~", ",", "^",
68+
"#", "_", "$", "?", "@", ".",
69+
} {
6870
help[v] = getBuiltin(helpVerbs, v, vcols)
6971
}
7072
for _, v := range []string{"'", "/", "\\"} {
7173
help[v] = getBuiltin(helpAdverbs, v, acols)
7274
}
73-
for _, v := range []string{"abs", "bytes", "uc", "error", "eval", "firsts", "json", "ocount", "panic",
75+
for _, v := range []string{
76+
"abs", "bytes", "uc", "error", "eval", "firsts", "json", "ocount", "panic",
7477
"sign", "csv", "in", "mod", "nan", "rotate", "sub", "utf8",
75-
"atan", "cos", "exp", "log", "round", "sin", "sqrt"} {
78+
"atan", "cos", "exp", "log", "round", "sin", "sqrt",
79+
} {
7680
help[v] = getBuiltin(helpNamedVerbs, v, nvcols)
7781
}
7882
help["¿"] = help["firsts"] + help["in"]
7983
for _, v := range []string{"rt.get", "rt.log", "rt.seed", "rt.time", "rt.try"} {
8084
help[v] = getBuiltin(helpRuntime, v, nvcols)
8185
}
82-
for _, v := range []string{"abspath", "chdir", "close", "dirfs", "env", "flush", "glob", "import", "mkdir", "open", "print",
83-
"read", "remove", "rename", "run", "say", "shell", "stat", "ARGS", "STDIN", "STDOUT", "STDERR"} {
86+
for _, v := range []string{
87+
"abspath", "chdir", "close", "dirfs", "env", "flush", "glob", "import", "mkdir", "open", "print",
88+
"read", "remove", "rename", "run", "say", "shell", "stat", "ARGS", "STDIN", "STDOUT", "STDERR",
89+
} {
8490
help[v] = getBuiltin(helpIO, v, nvcols)
8591
}
8692
help["subfs"] = help["dirfs"]
@@ -112,3 +118,7 @@ func getBuiltin(s string, v string, n int) string {
112118
}
113119
return sb.String()
114120
}
121+
122+
func Map() map[string]string {
123+
return initHelp()
124+
}

0 commit comments

Comments
 (0)