github.com/quantosnetwork/Quantos@v0.0.0-20220306172517-e20b28c5a29a/cmd/connect.go (about) 1 /* 2 Copyright © 2022 NAME HERE <EMAIL ADDRESS> 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 package cmd 17 18 import ( 19 "fmt" 20 "github.com/quantosnetwork/Quantos/protocol" 21 "github.com/spf13/cobra" 22 ) 23 24 // connectCmd represents the connect command 25 var connectCmd = &cobra.Command{ 26 Use: "connect", 27 Short: "A brief description of your command", 28 Long: `A longer description that spans multiple lines and likely contains examples 29 and usage of using your command. For example: 30 31 Cobra is a CLI library for Go that empowers applications. 32 This application is a tool to generate the needed files 33 to quickly create a Cobra application.`, 34 Run: func(cmd *cobra.Command, args []string) { 35 fmt.Println("connect called") 36 }, 37 } 38 39 var connectServerCmd = &cobra.Command{ 40 Use: "start-kex-server", 41 Short: "A brief description of your command", 42 Long: `A longer description that spans multiple lines and likely contains examples 43 and usage of using your command. For example: 44 45 Cobra is a CLI library for Go that empowers applications. 46 This application is a tool to generate the needed files 47 to quickly create a Cobra application.`, 48 Run: func(cmd *cobra.Command, args []string) { 49 host, _ := cmd.Flags().GetString("host") 50 port, _ := cmd.Flags().GetString("port") 51 52 protocol.StartKeyExchange(host, port) 53 }, 54 } 55 56 func init() { 57 rootCmd.AddCommand(connectCmd) 58 59 connectCmd.AddCommand(connectServerCmd) 60 connectServerCmd.PersistentFlags().String("host", "127.0.0.1", "set the host of the kex server") 61 connectServerCmd.PersistentFlags().String("port", "55225", "set the port of the kex server") 62 63 // Here you will define your flags and configuration settings. 64 65 // Cobra supports Persistent Flags which will work for this command 66 // and all subcommands, e.g.: 67 // connectCmd.PersistentFlags().String("foo", "", "A help for foo") 68 69 // Cobra supports local flags which will only run when this command 70 // is called directly, e.g.: 71 // connectCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 72 }