Beispiel #1
0
func debugCmdFuncInfo(c *cli.Context) {
	if log.GetLevel() < log.DebugLevel {
		return
	}

	// get function name
	dbgMsg := ""
	pc, _, _, ok := runtime.Caller(1)
	if ok {
		dbgMsg = runtime.FuncForPC(pc).Name()
		i := strings.LastIndex(dbgMsg, "/")
		if i != -1 {
			dbgMsg = dbgMsg[i+1:]
		}
	} else {
		dbgMsg = "<unknown function name>"
	}
	dbgMsg = fmt.Sprintf("func %s", dbgMsg)

	// get used flags
	for _, flag := range c.FlagNames() {
		dbgMsg = fmt.Sprintf("%s\n\t%s=%+v", dbgMsg, flag, c.Generic(flag))
	}
	log.Debugf(dbgMsg)
}
func ValidateMultiArgs(c *cli.Context) bool {
	if c.Generic("muser") == nil {
		return false
	}
	if c.Generic("mpassword") == nil {
		return false
	}
	return true
}
Beispiel #3
0
// serviced service add [[-p PORT]...] [[-q REMOTE]...] [--parent-id SERVICEID] NAME IMAGEID COMMAND
func (c *ServicedCli) cmdServiceAdd(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 3 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "add")
		return
	}

	var (
		parentService *service.Service
		err           error
	)
	if parentServiceID := ctx.String("parent-id"); parentServiceID == "" {
		fmt.Fprintln(os.Stderr, "Must specify a parent service ID")
		return
	} else if parentService, err = c.searchForService(parentServiceID); err != nil {
		fmt.Fprintf(os.Stderr, "Error searching for parent service: %s", err)
		return
	}

	cfg := api.ServiceConfig{
		Name:            args[0],
		ImageID:         args[1],
		Command:         args[2],
		ParentServiceID: parentService.ID,
		LocalPorts:      ctx.Generic("p").(*api.PortMap),
		RemotePorts:     ctx.Generic("q").(*api.PortMap),
	}

	if service, err := c.driver.AddService(cfg); err != nil {
		fmt.Fprintln(os.Stderr, err)
	} else if service == nil {
		fmt.Fprintln(os.Stderr, "received nil service definition")
	} else {
		fmt.Println(service.ID)
	}
}
Beispiel #4
0
func buildConvoyCmdArgs(c *cli.Context, socket string) []string {
	convoyCmd := []string{fmt.Sprintf(flagFmt, "socket", socket), "daemon"}
	for flagName, flagType := range convoyFlags {
		if !c.IsSet(flagName) {
			continue
		}
		f := c.Generic(flagName)
		flagName = flagName[len(convoyFlagNamePrefix):]
		logrus.Infof("Got: %s %v", flagName, f)
		switch flagType {
		case "string":
			fallthrough
		case "bool":
			fl := f.(flag.Getter)
			convoyCmd = append(convoyCmd, fmt.Sprintf(flagFmt, flagName, fl.String()))
		case "stringslice":
			fl := f.(*cli.StringSlice)
			for _, val := range fl.Value() {
				convoyCmd = append(convoyCmd, fmt.Sprintf(flagFmt, flagName, val))
			}
		}
	}
	return convoyCmd
}
func ValidateExtraArgs(c *cli.Context) bool {
	if c.Generic("legacy-dsn") == nil {
		return false
	}
	if c.Generic("legacy-user") == nil {
		return false
	}
	if c.Generic("legacy-password") == nil {
		return false
	}
	return true
}
func ValidateArgs(c *cli.Context) bool {
	if c.Generic("dsn") == nil {
		return false
	}
	if c.Generic("user") == nil {
		return false
	}
	if c.Generic("password") == nil {
		return false
	}
	return true
}