tag mode II
parent
59a4e22ee8
commit
1c1151ffd6
40
lib.go
40
lib.go
|
@ -88,6 +88,18 @@ func Tokens(str string) ([]string, error) {
|
|||
default:
|
||||
return nil, errors.New(fmt.Sprintf("Error at char %d - cant add space here. Mode: %s", i, mode.String()))
|
||||
}
|
||||
case '=':
|
||||
switch mode {
|
||||
case MODE_NORMAL:
|
||||
if sb.Len() > 0 {
|
||||
params = append(params, sb.String())
|
||||
sb = strings.Builder{}
|
||||
}
|
||||
params = append(params, "=")
|
||||
case MODE_STR, MODE_ESCAPE_STR:
|
||||
sb.WriteRune(a)
|
||||
}
|
||||
|
||||
case '\n':
|
||||
switch mode {
|
||||
case MODE_NORMAL:
|
||||
|
@ -105,13 +117,6 @@ func Tokens(str string) ([]string, error) {
|
|||
switch mode {
|
||||
case MODE_NORMAL:
|
||||
if sb.Len() > 0 {
|
||||
lchar := sb.String()[sb.Len()-1]
|
||||
if lchar == '=' {
|
||||
sb.WriteRune(a)
|
||||
mode = MODE_TAG
|
||||
continue
|
||||
}
|
||||
|
||||
params = append(params, sb.String())
|
||||
sb = strings.Builder{}
|
||||
mode = MODE_STR
|
||||
|
@ -122,7 +127,6 @@ func Tokens(str string) ([]string, error) {
|
|||
params = append(params, sb.String())
|
||||
sb = strings.Builder{}
|
||||
mode = MODE_NORMAL
|
||||
|
||||
case MODE_STR:
|
||||
params = append(params, sb.String())
|
||||
sb = strings.Builder{}
|
||||
|
@ -227,12 +231,12 @@ func Lines(str string) ([]Line, error) {
|
|||
Tokens: make([]string, 0),
|
||||
}
|
||||
default:
|
||||
//if len(line.Tokens) > 2 && line.Tokens[len(line.Tokens)-1] == "=" {
|
||||
// line.Tokens[len(line.Tokens)-2] = line.Tokens[len(line.Tokens)-2] + "=" + tk
|
||||
// line.Tokens = line.Tokens[:len(line.Tokens)-1]
|
||||
//} else {
|
||||
line.Tokens = append(line.Tokens, tk)
|
||||
//}
|
||||
if len(line.Tokens) > 2 && line.Tokens[len(line.Tokens)-1] == "=" {
|
||||
line.Tokens[len(line.Tokens)-2] = line.Tokens[len(line.Tokens)-2] + "=" + tk
|
||||
line.Tokens = line.Tokens[:len(line.Tokens)-1]
|
||||
} else {
|
||||
line.Tokens = append(line.Tokens, tk)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -308,17 +312,19 @@ func Exec(str string, opts ...*Opts) ([]*exec.Cmd, error) {
|
|||
if filepath.IsAbs(l.Tokens[1]) {
|
||||
cmdwd = l.Tokens[1]
|
||||
} else {
|
||||
cmdwd, err = filepath.Abs(filepath.Join(wd, l.Tokens[1]))
|
||||
cmdwd, err = filepath.Abs(filepath.Join(cmdwd, l.Tokens[1]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
log.Printf("CMDWD NOW IS: %s", cmdwd)
|
||||
if opt.Debug {
|
||||
log.Printf("CMDWD NOW IS: %s", cmdwd)
|
||||
}
|
||||
continue
|
||||
case LINETYPE_SERIAL:
|
||||
cmd := prepCmd(l)
|
||||
if opt.Debug {
|
||||
log.Printf("Running %s from dir %s with params %v", cmd.Path, cmd.Dir, cmd.Args)
|
||||
log.Printf("Running %s from dir %s with params %s", cmd.Path, cmd.Dir, strings.Join(cmd.Args, ","))
|
||||
}
|
||||
err = cmd.Run()
|
||||
if opt.Debug {
|
||||
|
|
Loading…
Reference in New Issue