mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	create the cli obj before calling parseCommand
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
		
							parent
							
								
									9c21a73f74
								
							
						
					
					
						commit
						c349c9d14a
					
				
					 2 changed files with 3 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -57,9 +57,7 @@ func (cli *DockerCli) getMethod(name string) (func(...string) error, bool) {
 | 
			
		|||
	return method.Interface().(func(...string) error), true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ParseCommands(proto, addr string, args ...string) error {
 | 
			
		||||
	cli := NewDockerCli(os.Stdin, os.Stdout, os.Stderr, proto, addr)
 | 
			
		||||
 | 
			
		||||
func (cli *DockerCli) ParseCommands(args ...string) error {
 | 
			
		||||
	if len(args) > 0 {
 | 
			
		||||
		method, exists := cli.getMethod(args[0])
 | 
			
		||||
		if !exists {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -148,7 +148,8 @@ func main() {
 | 
			
		|||
			log.Fatal("Please specify only one -H")
 | 
			
		||||
		}
 | 
			
		||||
		protoAddrParts := strings.SplitN(flHosts.GetAll()[0], "://", 2)
 | 
			
		||||
		if err := api.ParseCommands(protoAddrParts[0], protoAddrParts[1], flag.Args()...); err != nil {
 | 
			
		||||
		cli := api.NewDockerCli(os.Stdin, os.Stdout, os.Stderr, protoAddrParts[0], protoAddrParts[1])
 | 
			
		||||
		if err := cli.ParseCommands(flag.Args()...); err != nil {
 | 
			
		||||
			if sterr, ok := err.(*utils.StatusError); ok {
 | 
			
		||||
				if sterr.Status != "" {
 | 
			
		||||
					log.Println(sterr.Status)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue