package instruction import ( "fmt" "strings" ) type config struct { // File is the path to the file File string // Path is the configuration field path Path []string // Value if the value to add or update Value string } func (d *config) Build(_args string) error { // 1. extract action (sub command) split := strings.SplitN(_args, " ", 2) // 2. check path if len(split) < 2 { return fmt.Errorf("missing configuration path") } // 3. check path separator splitPath := strings.Split(split[0], "@") if len(splitPath) > 2 { return fmt.Errorf("invalid path (additional '@'?)") } d.File = splitPath[0] if len(splitPath) > 1 { // add field path only if set d.Path = strings.Split(splitPath[1], ".") } // add value d.Value = split[1] return nil } func (d config) Exec(ctx ExecutionContext) ([]byte, error) { return nil, nil }