func (c *SuperCommand) Run(ctx *Context) error {
	if c.showDescription {
		if c.Purpose != "" {
			fmt.Fprintf(ctx.Stdout, "%s\n", c.Purpose)
		} else {
			fmt.Fprintf(ctx.Stdout, "%s: no description available\n", c.Info().Name)
		}
		return nil
	}
	if c.action.command == nil {
		panic("Run: missing subcommand; Init failed or not called")
	}

	// Set the serialisable state on the context, by checking the common global
	// formatting directive. Set this early enough, so that everyone can take
	// appropriate action further down stream.
	ctx.serialisable = c.isSerialisableFormatDirective()

	if c.Log != nil {
		if err := c.Log.Start(ctx); err != nil {
			return err
		}
	}

	if c.notifyRun != nil {
		name := c.Name
		if c.usagePrefix != "" && c.usagePrefix != name {
			name = c.usagePrefix + " " + name
		}
		c.notifyRun(name)
	}
	if deprecated, replacement := c.action.Deprecated(); deprecated {
		ctx.Infof("WARNING: %q is deprecated, please use %q", c.action.name, replacement)
	}

	err := c.action.command.Run(ctx)
	if err != nil && !IsErrSilent(err) {
		// Handle formatting when displaying errors.
		handleErr := c.handleErrorForMachineFormats(ctx)
		if handleErr != nil {
			// If there is a handle error when attempting to find the machine
			// format, we should let the user know. In doing so, we dump the
			// original error and return the handle error so that effective
			// debugging is possible.
			logger.Debugf("error stack: \n%v", errors.ErrorStack(err))
			return handleErr
		}

		WriteError(ctx.Stderr, err)
		logger.Debugf("error stack: \n%v", errors.ErrorStack(err))

		// Err has been logged above, we can make the err silent so it does not log again in cmd/main
		if !IsRcPassthroughError(err) {
			err = ErrSilent
		}
	} else {
		logger.Infof("command finished")
	}
	return err
}
// Run executes the subcommand that was selected in Init.
Run executes the subcommand that was selected in Init.
// Run executes the subcommand that was selected in Init .
func (c *SuperCommand) Run(ctx *Context) error {
	if c.showDescription {
		if c.Purpose != "" {
			fmt.Fprintf(ctx.Stdout, "%s\n", c.Purpose)
		} else {
			fmt.Fprintf(ctx.Stdout, "%s: no description available\n", c.Info().Name)
		}
		return nil
	}
	if c.action.command == nil {
		panic("Run: missing subcommand; Init failed or not called")
	}
	ctx.serialisable = c.isSerialisableFormatDirective()
	if c.Log != nil {
		if err := c.Log.Start(ctx); err != nil {
			return err
		}
	}
	if c.notifyRun != nil {
		name := c.Name
		if c.usagePrefix != "" && c.usagePrefix != name {
			name = c.usagePrefix + " " + name
		}
		c.notifyRun(name)
	}
	if deprecated, replacement := c.action.Deprecated(); deprecated {
		ctx.Infof("WARNING: %q is deprecated, please use %q", c.action.name, replacement)
	}
	err := c.action.command.Run(ctx)
	if err != nil && !IsErrSilent(err) {
		handleErr := c.handleErrorForMachineFormats(ctx)
		if handleErr != nil {
			logger.Debugf("error stack: \n%v", errors.ErrorStack(err))
			return handleErr
		}
		WriteError(ctx.Stderr, err)
		logger.Debugf("error stack: \n%v", errors.ErrorStack(err))
		if !IsRcPassthroughError(err) {
			err = ErrSilent
		}
	} else {
		logger.Infof("command finished")
	}
	return err
}
func ( c * SuperCommand ) Run ( ctx * Context ) error { if c . showDescription { if c . Purpose != " " { fmt . Fprintf ( ctx . Stdout , " \n " , c . Purpose ) } else { fmt . Fprintf ( ctx . Stdout , " \n " , c . Info ( ) . Name ) } return nil } if c . action . command == nil { panic ( " " ) } ctx . serialisable = c . isSerialisableFormatDirective ( ) if c . Log != nil { if err := c . Log . Start ( ctx ) ; err != nil { return err } } if c . notifyRun != nil { name := c . Name if c . usagePrefix != " " && c . usagePrefix != name { name = c . usagePrefix + " " + name } c . notifyRun ( name ) } if deprecated , replacement := c . action . Deprecated ( ) ; deprecated { ctx . Infof ( " " , c . action . name , replacement ) } err := c . action . command . Run ( ctx ) if err != nil && ! IsErrSilent ( err ) { handleErr := c . handleErrorForMachineFormats ( ctx ) if handleErr != nil { logger . Debugf ( " \n " , errors . ErrorStack ( err ) ) return handleErr } WriteError ( ctx . Stderr , err ) logger . Debugf ( " \n " , errors . ErrorStack ( err ) ) if ! IsRcPassthroughError ( err ) { err = ErrSilent } } else { logger . Infof ( " " ) } return err }
Run executes the subcommand that was selected in Init.
Run executes the subcommand that was selected in Init .
// Set the serialisable state on the context, by checking the common global // formatting directive. Set this early enough, so that everyone can take // appropriate action further down stream. // Handle formatting when displaying errors. // If there is a handle error when attempting to find the machine // format, we should let the user know. In doing so, we dump the // original error and return the handle error so that effective // debugging is possible. // Err has been logged above, we can make the err silent so it does not log again in cmd/main