func (p4 *P4) Save(specName string, specContents map[string]string, args []string) ([]map[interface{}]interface{}, error) {
	opts := p4.getOptions()
	nargs := []string{specName, "-i"}
	nargs = append(nargs, args...)
	args = append(opts, nargs...)

	log.Println(args)
	cmd := exec.Command("p4", args...)
	var stdout, stderr bytes.Buffer
	stdin, err := cmd.StdinPipe()
	if err != nil {
		fmt.Println("An error occured: ", err)
	}
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	mainerr := cmd.Start()
	if mainerr != nil {
		fmt.Println("An error occured: ", mainerr)
	}
	spec := formatSpec(specContents)
	log.Println(spec)
	io.WriteString(stdin, spec)
	stdin.Close()
	cmd.Wait()

	results := make([]map[interface{}]interface{}, 0)
	for {
		r, err := Unmarshal(&stdout)
		if err == io.EOF || r == nil {
			break
		}
		if err == nil {
			results = append(results, r.(map[interface{}]interface{}))
			fmt.Println(r)
		} else {
			if mainerr == nil {
				mainerr = err
			}
			break
		}
	}
	return results, mainerr
}
// Save - runs p4 -i for specified spec returns result
runs p4 -i for specified spec returns result
// Save - runs p4 - i for specified spec returns result
func (p4 *P4) Save(specName string, specContents map[string]string, args []string) ([]map[interface{}]interface{}, error) {
	opts := p4.getOptions()
	nargs := []string{specName, "-i"}
	nargs = append(nargs, args...)
	args = append(opts, nargs...)
	log.Println(args)
	cmd := exec.Command("p4", args...)
	var stdout, stderr bytes.Buffer
	stdin, err := cmd.StdinPipe()
	if err != nil {
		fmt.Println("An error occured: ", err)
	}
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	mainerr := cmd.Start()
	if mainerr != nil {
		fmt.Println("An error occured: ", mainerr)
	}
	spec := formatSpec(specContents)
	log.Println(spec)
	io.WriteString(stdin, spec)
	stdin.Close()
	cmd.Wait()
	results := make([]map[interface{}]interface{}, 0)
	for {
		r, err := Unmarshal(&stdout)
		if err == io.EOF || r == nil {
			break
		}
		if err == nil {
			results = append(results, r.(map[interface{}]interface{}))
			fmt.Println(r)
		} else {
			if mainerr == nil {
				mainerr = err
			}
			break
		}
	}
	return results, mainerr
}
func ( p4 * P4 ) Save ( specName string , specContents map [ string ] string , args [ ] string ) ( [ ] map [ interface { } ] interface { } , error ) { opts := p4 . getOptions ( ) nargs := [ ] string { specName , " " } nargs = append ( nargs , args ... ) args = append ( opts , nargs ... ) log . Println ( args ) cmd := exec . Command ( " " , args ... ) var stdout , stderr bytes . Buffer stdin , err := cmd . StdinPipe ( ) if err != nil { fmt . Println ( " " , err ) } cmd . Stdout = & stdout cmd . Stderr = & stderr mainerr := cmd . Start ( ) if mainerr != nil { fmt . Println ( " " , mainerr ) } spec := formatSpec ( specContents ) log . Println ( spec ) io . WriteString ( stdin , spec ) stdin . Close ( ) cmd . Wait ( ) results := make ( [ ] map [ interface { } ] interface { } , 0 ) for { r , err := Unmarshal ( & stdout ) if err == io . EOF || r == nil { break } if err == nil { results = append ( results , r . ( map [ interface { } ] interface { } ) ) fmt . Println ( r ) } else { if mainerr == nil { mainerr = err } break } } return results , mainerr }
runs p4 -i for specified spec returns result
runs p4 - i for specified spec returns result