fixed the parsing of "-"
This commit is contained in:
parent
67a38e62fb
commit
990978f157
@ -26,9 +26,11 @@ func parse(input string) Input {
|
||||
instruction := strings.TrimSpace(split[0])
|
||||
var flags []string
|
||||
var args []string
|
||||
|
||||
|
||||
for _, arg := range split[1:] {
|
||||
if arg[0:2] == "--" {
|
||||
if len(arg) == 1 && arg[0] == '-' {
|
||||
continue
|
||||
} else if arg[0:2] == "--" {
|
||||
var result = strings.TrimSpace(arg)
|
||||
flags = append(flags, string(result[2:]))
|
||||
continue
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
test := parse("ls -abcd hej -ee tbtry --help")
|
||||
test := parse("ls -abcd hej -ee tbtry --help - -o")
|
||||
fmt.Println(test.Instruction)
|
||||
fmt.Println(test.Args)
|
||||
fmt.Println(test.Flags)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user