github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/cmd/compilers.go (about) 1 // Copyright © 2016 NAME HERE <EMAIL ADDRESS> 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package cmd 16 17 import ( 18 "fmt" 19 "os" 20 "strings" 21 22 "github.com/sirupsen/logrus" 23 "github.com/spf13/cobra" 24 25 "github.com/solo-io/unik/pkg/client" 26 ) 27 28 var compilersCmd = &cobra.Command{ 29 Use: "compilers", 30 Short: "List available unikernel compilers", 31 Long: `Returns a list of compilers available to the targeted unik backend.`, 32 Run: func(cmd *cobra.Command, args []string) { 33 if err := func() error { 34 if err := readClientConfig(); err != nil { 35 return err 36 } 37 if host == "" { 38 host = clientConfig.Host 39 } 40 logrus.WithField("host", host).Info("listing compilers") 41 compilers, err := client.UnikClient(host).AvailableCompilers() 42 if err != nil { 43 return err 44 } 45 fmt.Printf("%s\n", strings.Join(compilers, "\n")) 46 return nil 47 }(); err != nil { 48 logrus.Errorf("failed listing compilers: %v", err) 49 os.Exit(-1) 50 } 51 }, 52 } 53 54 func init() { 55 RootCmd.AddCommand(compilersCmd) 56 }