Skip to content

Commit 90e5d23

Browse files
init tests
1 parent 16423c2 commit 90e5d23

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

docs_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package docs
33
import (
44
"bytes"
55
"embed"
6+
"fmt"
67
"io"
78
"io/fs"
89
"net/mail"
@@ -62,6 +63,11 @@ func buildExtendedTestCommand() *cli.Command {
6263
Name: "hidden-flag",
6364
Hidden: true,
6465
},
66+
&cli.StringFlag{
67+
Name: "dir",
68+
Value: pwd(),
69+
DefaultText: "$PWD",
70+
},
6571
},
6672
Commands: []*cli.Command{{
6773
Aliases: []string{"c"},
@@ -182,6 +188,14 @@ func TestToTabularMarkdown(t *testing.T) {
182188
})
183189
}
184190

191+
func pwd() string {
192+
pwd, err := os.Getwd()
193+
if err != nil {
194+
fmt.Println(err)
195+
}
196+
return pwd
197+
}
198+
185199
func TestToTabularMarkdownFailed(t *testing.T) {
186200
tpl := MarkdownTabularDocTemplate
187201
t.Cleanup(func() { MarkdownTabularDocTemplate = tpl })

testdata/expected-doc-full.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ greet
88

99
```
1010
[--another-flag|-b]
11+
[--dir]=[value]
1112
[--flag|--fl|-f]=[value]
1213
[--socket|-s]=[value]
1314
```
@@ -26,6 +27,8 @@ app [first_arg] [second_arg]
2627

2728
**--another-flag, -b**: another usage text
2829

30+
**--dir**="": (default: $PWD)
31+
2932
**--flag, --fl, -f**="":
3033

3134
**--socket, -s**="": some 'usage' text (default: value)

testdata/expected-tabular-markdown-full.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Global flags:
1919
| `--socket="…"` (`-s`) | some 'usage' text | `value` | *none* |
2020
| `--flag="…"` (`--fl`, `-f`) | | | *none* |
2121
| `--another-flag` (`-b`) | another usage text | `false` | `EXAMPLE_VARIABLE_NAME` |
22+
| `--dir="…"` | | `$PWD` | *none* |
2223

2324
### `config` command (aliases: `c`)
2425

0 commit comments

Comments
 (0)