func newCmd()

in pkg/cmd/events/events.go [91:112]


func newCmd() *cobra.Command {
	var cmd = &cobra.Command{
		Use:     "events [--code CODE] [--state STATE] [--not-after] [--not-before-deadline]",
		Aliases: []string{"se", "scheduledevents"},
		PreRunE: preRun,
		Example: fmt.Sprintf("  %s events -h \tevents help \n  %s events -o instance-stop --state active -d\t\tmocks an active and upcoming scheduled event for instance stop with a deadline for the event start time", cmdutil.BinName, cmdutil.BinName),
		Run:     run,
		Short:   "Mock EC2 maintenance events",
		Long:    "Mock EC2 maintenance events",
	}

	// local flags
	cmd.Flags().StringP(eventCodeFlagName, "o", "", "event code in the scheduled event (default: system-reboot)\nevent-code can be one of the following: "+strings.Join(validEventCodes, ","))
	cmd.Flags().StringP(eventStateFlagName, "t", "", "state of the scheduled event (default: active)\nstate can be one of the following: "+strings.Join(validEventStates, ","))
	cmd.Flags().StringP(notBeforeFlagName, "b", "", "the earliest start time for the scheduled event in RFC3339 format E.g. 2020-01-07T01:03:47Z (default: application start time in UTC)")
	cmd.Flags().StringP(notAfterFlagName, "a", "", "the latest end time for the scheduled event in RFC3339 format E.g. 2020-01-07T01:03:47Z default: application start time + 7 days in UTC))")
	cmd.Flags().StringP(notBeforeDeadlineFlagName, "l", "", "the deadline for starting the event in RFC3339 format E.g. 2020-01-07T01:03:47Z (default: application start time + 9 days in UTC)")

	// bind local flags to config
	cfg.BindFlagSetWithKeyPrefix(cmd.Flags(), cfgPrefix)
	return cmd
}