github.com/fanux/shipyard@v0.0.0-20161009071005-6515ce223235/controller/plugin/plugin_pipeline/cmd/start.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 "log" 19 20 "github.com/spf13/cobra" 21 ) 22 23 var ( 24 ManagerHost string 25 ManagerPort string 26 ) 27 28 // startCmd represents the start command 29 var startCmd = &cobra.Command{ 30 Use: "start", 31 Short: "start a plugin", 32 Long: `start a plugin`, 33 Run: func(cmd *cobra.Command, args []string) { 34 // TODO: Work your own magic here 35 log.Printf("plugin manager server info %s%s\n", ManagerHost, ManagerPort) 36 startCron(ManagerHost, ManagerPort) 37 //fmt.Println("start called") 38 }, 39 } 40 41 func init() { 42 RootCmd.AddCommand(startCmd) 43 44 // Here you will define your flags and configuration settings. 45 46 // Cobra supports Persistent Flags which will work for this command 47 // and all subcommands, e.g.: 48 // startCmd.PersistentFlags().String("foo", "", "A help for foo") 49 50 // Cobra supports local flags which will only run when this command 51 // is called directly, e.g.: 52 // startCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 53 startCmd.Flags().StringVarP(&ManagerHost, "manager-host", "H", "localhost", "the ip address of plugin manager server") 54 startCmd.Flags().StringVarP(&ManagerPort, "manager-port", "p", ":8081", "the port of plugin manager server") 55 }