Clean up Cobra files
This commit is contained in:
parent
2571936a48
commit
b6e133c608
|
@ -10,7 +10,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// clientCmd represents the client command
|
|
||||||
var clientCmd = &cobra.Command{
|
var clientCmd = &cobra.Command{
|
||||||
Use: "client",
|
Use: "client",
|
||||||
Short: "Client interface for mini-chat",
|
Short: "Client interface for mini-chat",
|
||||||
|
@ -35,18 +34,8 @@ Example:
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(clientCmd)
|
rootCmd.AddCommand(clientCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
|
||||||
|
|
||||||
// Cobra supports Persistent Flags which will work for this command
|
|
||||||
// and all subcommands, e.g.:
|
|
||||||
// clientCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
||||||
clientCmd.PersistentFlags().StringP("ip", "i", "", "Server IP to connect to")
|
clientCmd.PersistentFlags().StringP("ip", "i", "", "Server IP to connect to")
|
||||||
clientCmd.PersistentFlags().StringP("port", "p", "1302", "Server port to connect to")
|
clientCmd.PersistentFlags().StringP("port", "p", "1302", "Server port to connect to")
|
||||||
|
|
||||||
// Cobra supports local flags which will only run when this command
|
|
||||||
// is called directly, e.g.:
|
|
||||||
// clientCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setClientParameters(cmd *cobra.Command) error {
|
func setClientParameters(cmd *cobra.Command) error {
|
||||||
|
|
15
cmd/root.go
15
cmd/root.go
|
@ -9,19 +9,13 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// rootCmd represents the base command when called without any subcommands
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "mini-chat",
|
Use: "mini-chat",
|
||||||
Short: "Application for hosting and joining a simple chat server",
|
Short: "Application for hosting and joining a simple chat server",
|
||||||
|
|
||||||
Long: `Application for hosting and joining a simple chat server`,
|
Long: `Application for hosting and joining a simple chat server`,
|
||||||
// Uncomment the following line if your bare application
|
|
||||||
// has an action associated with it:
|
|
||||||
// Run: func(cmd *cobra.Command, args []string) { },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
|
||||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
|
||||||
func Execute() {
|
func Execute() {
|
||||||
err := rootCmd.Execute()
|
err := rootCmd.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -30,13 +24,4 @@ func Execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Here you will define your flags and configuration settings.
|
|
||||||
// Cobra supports persistent flags, which, if defined here,
|
|
||||||
// will be global for your application.
|
|
||||||
|
|
||||||
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.chat-tests.yaml)")
|
|
||||||
|
|
||||||
// Cobra also supports local flags, which will only run
|
|
||||||
// when this action is called directly.
|
|
||||||
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// serverCmd represents the server command
|
|
||||||
var serverCmd = &cobra.Command{
|
var serverCmd = &cobra.Command{
|
||||||
Use: "server",
|
Use: "server",
|
||||||
Short: "Tiny chat server",
|
Short: "Tiny chat server",
|
||||||
|
@ -30,18 +29,8 @@ Example:
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(serverCmd)
|
rootCmd.AddCommand(serverCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
|
||||||
|
|
||||||
// Cobra supports Persistent Flags which will work for this command
|
|
||||||
// and all subcommands, e.g.:
|
|
||||||
// serverCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
||||||
serverCmd.PersistentFlags().StringP("port", "p", "1302", "port to use for listening")
|
serverCmd.PersistentFlags().StringP("port", "p", "1302", "port to use for listening")
|
||||||
serverCmd.PersistentFlags().StringP("history", "r", "", "File to store and recover chat history from")
|
serverCmd.PersistentFlags().StringP("history", "r", "", "File to store and recover chat history from")
|
||||||
|
|
||||||
// Cobra supports local flags which will only run when this command
|
|
||||||
// is called directly, e.g.:
|
|
||||||
// serverCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setServerParameters(cmd *cobra.Command) error {
|
func setServerParameters(cmd *cobra.Command) error {
|
||||||
|
|
Loading…
Reference in New Issue