fixed the parsing of "-"

This commit is contained in:
Laukka 2025-01-12 14:26:50 +01:00
parent 67a38e62fb
commit 990978f157
2 changed files with 5 additions and 3 deletions

View File

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

View File

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