This commit is contained in:
Arpad Ryszka 2025-09-11 21:16:39 +02:00
parent 1b2c55d990
commit 434309bf34
8 changed files with 35 additions and 8 deletions

BIN
.bin/wand

Binary file not shown.

View File

@ -35,7 +35,7 @@ docreflect.gen.go: $(SOURCES)
docreflect_test.go: $(SOURCES) docreflect_test.go: $(SOURCES)
go run script/docreflect/docs.go \ go run script/docreflect/docs.go \
wand_test \ wand \
code.squareroundforest.org/arpio/wand/internal/tests/testlib \ code.squareroundforest.org/arpio/wand/internal/tests/testlib \
> docreflect_test.go \ > docreflect_test.go \
|| rm -f docreflect_test.go || rm -f docreflect_test.go
@ -53,5 +53,6 @@ clean:
go clean ./... go clean ./...
rm -rf .build rm -rf .build
rm -f docreflect.gen.go rm -f docreflect.gen.go
rm -f docreflect_test.go
rm -f iniparser.gen.go rm -f iniparser.gen.go
rm -f .cover rm -f .cover

View File

@ -3,7 +3,7 @@ Generated with https://code.squareroundforest.org/arpio/docreflect
*/ */
package wand_test package wand
import "code.squareroundforest.org/arpio/docreflect" import "code.squareroundforest.org/arpio/docreflect"
func init() { func init() {
docreflect.Register("code.squareroundforest.org/arpio/wand/internal/tests/testlib", "") docreflect.Register("code.squareroundforest.org/arpio/wand/internal/tests/testlib", "")

17
env.go
View File

@ -68,3 +68,20 @@ func readEnv(appName string, input []string) env {
return e 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 ""
}

View File

@ -4,7 +4,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"os"
"path/filepath" "path/filepath"
"strconv" "strconv"
) )
@ -17,7 +16,7 @@ func exec(stdin io.Reader, stdout, stderr io.Writer, exit func(int), cmd Cmd, co
return return
} }
if os.Getenv("_wandgenerate") == "man" { if getenv(env, "_wandgenerate") == "man" {
if err := generateMan(stdout, cmd, conf); err != nil { if err := generateMan(stdout, cmd, conf); err != nil {
fmt.Fprintln(stderr, err) fmt.Fprintln(stderr, err)
exit(1) exit(1)
@ -26,8 +25,8 @@ func exec(stdin io.Reader, stdout, stderr io.Writer, exit func(int), cmd Cmd, co
return return
} }
if os.Getenv("_wandgenerate") == "markdown" { if getenv(env, "_wandgenerate") == "markdown" {
level, _ := strconv.Atoi(os.Getenv("_wandmarkdownlevel")) level, _ := strconv.Atoi(getenv(env, "_wandmarkdownlevel"))
if err := generateMarkdown(stdout, cmd, conf, level); err != nil { if err := generateMarkdown(stdout, cmd, conf, level); err != nil {
fmt.Fprintln(stderr, err) fmt.Fprintln(stderr, err)
exit(1) exit(1)

9
license Normal file
View File

@ -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.

View File

@ -1,5 +1,8 @@
turn testExec into a wandtesting package turn testExec into a wandtesting package
use a type cache use a type cache
check the teletype width for rendering
provide option for the markdown rendering width
support HTML doc rendering
test: test:
- nil return values - nil return values
- options in variadic - options in variadic

View File

@ -8,8 +8,6 @@ import (
) )
func TestOutput(t *testing.T) { func TestOutput(t *testing.T) {
// multiple, mixed outputs
f0 := func() any { return nil } f0 := func() any { return nil }
f1 := func() int { return 42 } f1 := func() int { return 42 }
f2 := func() time.Duration { return 9 * time.Second } f2 := func() time.Duration { return 9 * time.Second }