github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/cmd_wait.go (about)

     1  // Copyright (C) 2015 Scaleway. All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE.md file.
     4  
     5  package cli
     6  
     7  import "github.com/scaleway/scaleway-cli/pkg/commands"
     8  
     9  var cmdWait = &Command{
    10  	Exec:        runWait,
    11  	UsageLine:   "wait [OPTIONS] SERVER [SERVER...]",
    12  	Description: "Block until a server stops",
    13  	Help:        "Block until a server stops.",
    14  }
    15  
    16  func init() {
    17  	cmdWait.Flag.BoolVar(&waitHelp, []string{"h", "-help"}, false, "Print usage")
    18  }
    19  
    20  // Flags
    21  var waitHelp bool // -h, --help flag
    22  
    23  func runWait(cmd *Command, rawArgs []string) error {
    24  	if waitHelp {
    25  		return cmd.PrintUsage()
    26  	}
    27  	if len(rawArgs) < 1 {
    28  		return cmd.PrintShortUsage()
    29  	}
    30  
    31  	args := commands.WaitArgs{
    32  		Servers: rawArgs,
    33  	}
    34  	ctx := cmd.GetContext(rawArgs)
    35  	return commands.RunWait(ctx, args)
    36  }