gosh/command.go

37 lines
617 B
Go

package main
import (
"strings"
"time"
)
type Command struct {
rowid int64
Args string
Times []int64
}
func (c Command) String() string {
return c.Args
}
/*
* Transitional method to import from the ruby implementation
*/
func CommandFromLineImport(line string) (*Command, error) {
line_chunks := strings.SplitN(strings.TrimSpace(line), " ", 3)
t, err := time.Parse(ShellTime, strings.Join(line_chunks[0:2], " "))
if err != nil {
return nil, err
}
if len(line_chunks) < 3 {
return &Command{Time: t}, nil
}
return &Command{
Args: strings.TrimSpace(line_chunks[2], " "),
Time: t,
}, nil
}