Skip to content

Commit dbb943b

Browse files
committedApr 5, 2020
update readme.
1 parent 0e2b0be commit dbb943b

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed
 

‎README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ Documentation can be found at [Godoc](https://godoc.org/github.com/cosiner/argv)
1313
# Example
1414
```Go
1515
func TestArgv(t *testing.T) {
16-
args, err := argv.Argv([]rune(" ls `echo /` | wc -l "), argv.ParseEnv(os.Environ()), argv.Run)
16+
args, err := Argv(" ls `echo /` | wc -l ", func(backquoted string) (string, error) {
17+
return backquoted, nil
18+
}, nil)
1719
if err != nil {
18-
t.Fatal(err)
20+
t.Fatal(err)
1921
}
2022
expects := [][]string{
21-
[]string{"ls", "/"},
22-
[]string{"wc", "-l"},
23+
[]string{"ls", "echo /"},
24+
[]string{"wc", "-l"},
2325
}
2426
if !reflect.DeepEqual(args, expects) {
25-
t.Fatal(args)
27+
t.Fatal(args)
2628
}
2729
}
2830
```

‎argv_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,19 @@ func TestArgv(t *testing.T) {
5454
}
5555
}
5656
}
57+
58+
func TestArgv2(t *testing.T) {
59+
args, err := Argv(" ls `echo /` | wc -l ", func(backquoted string) (string, error) {
60+
return backquoted, nil
61+
}, nil)
62+
if err != nil {
63+
t.Fatal(err)
64+
}
65+
expects := [][]string{
66+
[]string{"ls", "echo /"},
67+
[]string{"wc", "-l"},
68+
}
69+
if !reflect.DeepEqual(args, expects) {
70+
t.Fatal(args)
71+
}
72+
}

0 commit comments

Comments
 (0)
Please sign in to comment.