|
1 | 1 | package cli |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "github.com/spf13/cobra" |
5 | | - |
6 | 4 | "github.com/getstackhead/stackhead-cli/routines" |
| 5 | + "github.com/spf13/cobra" |
7 | 6 | ) |
8 | 7 |
|
9 | 8 | // Validate is a command object for Cobra that provides the validate command |
10 | | -var Validate = &cobra.Command{ |
11 | | - Use: "validate [path to StackHead CLI configuration file]", |
12 | | - Example: "validate ./stackhead-module.yml", |
13 | | - Short: "Validate a StackHead module file", |
14 | | - Long: `validate is used to make sure your StackHead CLI configuration file meets the required syntax.`, |
15 | | - Args: cobra.ExactArgs(1), |
16 | | - Run: func(cmd *cobra.Command, args []string) { |
17 | | - routines.Validate(args[0], "cli-config.schema.json") |
18 | | - }, |
| 9 | +func Validate() *cobra.Command { |
| 10 | + var version, branch string |
| 11 | + var ignoreSslCertificate bool |
| 12 | + var command = &cobra.Command{ |
| 13 | + Use: "validate [path to StackHead CLI configuration file]", |
| 14 | + Example: "validate ./stackhead-module.yml", |
| 15 | + Short: "Validate a StackHead module file", |
| 16 | + Long: `validate is used to make sure your StackHead CLI configuration file meets the required syntax.`, |
| 17 | + Args: cobra.ExactArgs(1), |
| 18 | + Run: routines.CobraValidationBase( |
| 19 | + "stackhead_cli", |
| 20 | + "cli-config.schema.json", |
| 21 | + version, |
| 22 | + branch, |
| 23 | + ignoreSslCertificate, |
| 24 | + ), |
| 25 | + } |
| 26 | + command.PersistentFlags().StringVar(&version, "version", "", "Version of schema to use (requires internet connection)") |
| 27 | + command.PersistentFlags().StringVar(&branch, "branch", "", "Branch of schema to use (requires internet connection)") |
| 28 | + command.PersistentFlags().BoolVar(&ignoreSslCertificate, "ignore-ssl-certificate", false, "Whether to ignore the SSL certificate for Web request (when --version) is used") |
| 29 | + |
| 30 | + return command |
19 | 31 | } |
0 commit comments