diff --git a/.bin/wand b/.bin/wand deleted file mode 100755 index 6e21193..0000000 Binary files a/.bin/wand and /dev/null differ diff --git a/Makefile b/Makefile index e33492b..430d870 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ docreflect.gen.go: $(SOURCES) docreflect_test.go: $(SOURCES) go run script/docreflect/docs.go \ - wand_test \ + wand \ code.squareroundforest.org/arpio/wand/internal/tests/testlib \ > docreflect_test.go \ || rm -f docreflect_test.go @@ -53,5 +53,6 @@ clean: go clean ./... rm -rf .build rm -f docreflect.gen.go + rm -f docreflect_test.go rm -f iniparser.gen.go rm -f .cover diff --git a/docreflect_test.go b/docreflect_test.go index d665ad9..40d978d 100644 --- a/docreflect_test.go +++ b/docreflect_test.go @@ -3,7 +3,7 @@ Generated with https://code.squareroundforest.org/arpio/docreflect */ -package wand_test +package wand import "code.squareroundforest.org/arpio/docreflect" func init() { docreflect.Register("code.squareroundforest.org/arpio/wand/internal/tests/testlib", "") diff --git a/env.go b/env.go index a7e9138..f3a84fe 100644 --- a/env.go +++ b/env.go @@ -68,3 +68,20 @@ func readEnv(appName string, input []string) env { return e } + +func getenv(env []string, name string) string { + for _, ei := range env { + eip := strings.Split(ei, "=") + if len(eip) < 2 { + continue + } + + if eip[0] != name { + continue + } + + return strings.Join(eip[1:], "=") + } + + return "" +} diff --git a/exec.go b/exec.go index d1722b7..f956b14 100644 --- a/exec.go +++ b/exec.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "os" "path/filepath" "strconv" ) @@ -17,7 +16,7 @@ func exec(stdin io.Reader, stdout, stderr io.Writer, exit func(int), cmd Cmd, co return } - if os.Getenv("_wandgenerate") == "man" { + if getenv(env, "_wandgenerate") == "man" { if err := generateMan(stdout, cmd, conf); err != nil { fmt.Fprintln(stderr, err) exit(1) @@ -26,8 +25,8 @@ func exec(stdin io.Reader, stdout, stderr io.Writer, exit func(int), cmd Cmd, co return } - if os.Getenv("_wandgenerate") == "markdown" { - level, _ := strconv.Atoi(os.Getenv("_wandmarkdownlevel")) + if getenv(env, "_wandgenerate") == "markdown" { + level, _ := strconv.Atoi(getenv(env, "_wandmarkdownlevel")) if err := generateMarkdown(stdout, cmd, conf, level); err != nil { fmt.Fprintln(stderr, err) exit(1) diff --git a/license b/license new file mode 100644 index 0000000..04ed07d --- /dev/null +++ b/license @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2025 Arpad Ryszka + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/notes.txt b/notes.txt index 6df9ef0..ebc97a6 100644 --- a/notes.txt +++ b/notes.txt @@ -1,5 +1,8 @@ turn testExec into a wandtesting package use a type cache +check the teletype width for rendering +provide option for the markdown rendering width +support HTML doc rendering test: - nil return values - options in variadic diff --git a/output_test.go b/output_test.go index 515127e..62c6b6e 100644 --- a/output_test.go +++ b/output_test.go @@ -8,8 +8,6 @@ import ( ) func TestOutput(t *testing.T) { - // multiple, mixed outputs - f0 := func() any { return nil } f1 := func() int { return 42 } f2 := func() time.Duration { return 9 * time.Second }