NewRunner returns a command runner.
(parent string)
| 35 | |
| 36 | // NewRunner returns a command runner. |
| 37 | func NewRunner(parent string) *Runner { |
| 38 | r := &Runner{} |
| 39 | c := &cobra.Command{ |
| 40 | Use: "init DIR", |
| 41 | Args: cobra.ExactArgs(1), |
| 42 | Short: docs.InitShort, |
| 43 | Long: docs.InitShort + "\n" + docs.InitLong, |
| 44 | Example: docs.InitExamples, |
| 45 | RunE: r.runE, |
| 46 | PreRunE: r.preRunE, |
| 47 | } |
| 48 | |
| 49 | c.Flags().StringVar(&r.Description, "description", "sample description", "short description of the package.") |
| 50 | c.Flags().StringVar(&r.Name, "name", "", "package name. defaults to the directory base name.") |
| 51 | c.Flags().StringSliceVar(&r.Tags, "tag", []string{}, "list of tags for the package.") |
| 52 | c.Flags().StringVar(&r.URL, "url", "", "link to page with information about the package.") |
| 53 | cmdutil.FixDocs("kpt", parent, c) |
| 54 | r.Command = c |
| 55 | return r |
| 56 | } |
| 57 | |
| 58 | func NewCommand(parent string) *cobra.Command { |
| 59 | return NewRunner(parent).Command |