github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/cmd/describe-compiler.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/sirupsen/logrus" 8 "github.com/spf13/cobra" 9 10 "github.com/emc-advanced-dev/pkg/errors" 11 "github.com/solo-io/unik/pkg/client" 12 ) 13 14 var describeCompilerCmd = &cobra.Command{ 15 Use: "describe-compiler", 16 Short: "Describe compiler usage", 17 Long: `Describes compiler usage. 18 You must provide triple base-language-provider to specify what compiler to describe.`, 19 Run: func(cmd *cobra.Command, args []string) { 20 if err := func() error { 21 // Determine host. 22 if err := readClientConfig(); err != nil { 23 return err 24 } 25 if host == "" { 26 host = clientConfig.Host 27 } 28 logrus.WithField("host", host).Info("listing providers") 29 30 // Validate input. 31 if base == "" { 32 return errors.New("--base must be set", nil) 33 } 34 if lang == "" { 35 return errors.New("--language must be set", nil) 36 } 37 if provider == "" { 38 return errors.New("--provider must be set", nil) 39 } 40 logrus.WithFields(logrus.Fields{ 41 "base": base, 42 "lang": lang, 43 "provider": provider, 44 }).Info("describe compiler") 45 46 // Ask daemon. 47 description, err := client.UnikClient(host).DescribeCompiler(base, lang, provider) 48 if err != nil { 49 return err 50 } 51 52 // Print result to the console. 53 fmt.Println(description) 54 55 return nil 56 }(); err != nil { 57 logrus.Errorf("failed describing compiler: %v", err) 58 os.Exit(-1) 59 } 60 }, 61 } 62 63 func init() { 64 RootCmd.AddCommand(describeCompilerCmd) 65 describeCompilerCmd.Flags().StringVar(&base, "base", "", "<string,required> name of the unikernel base to use") 66 describeCompilerCmd.Flags().StringVar(&lang, "language", "", "<string,required> language the unikernel source is written in") 67 describeCompilerCmd.Flags().StringVar(&provider, "provider", "", "<string,required> name of the target infrastructure to compile for") 68 }