cmd

package
v2.4.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2017 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use: "chkit",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		if debug, _ := cmd.Flags().GetBool("debug"); debug {
			np = jww.NewNotepad(jww.LevelDebug, jww.LevelDebug, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
		} else {
			np = jww.NewNotepad(jww.LevelInfo, jww.LevelInfo, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
		}
		db, err := dbconfig.OpenOrCreate(chlib.ConfigFile, np)
		exitOnErr(err)
		apiConfig, err := db.GetHttpApiConfig()
		exitOnErr(err)
		tcpApiConfig, err := db.GetTcpApiConfig()
		exitOnErr(err)
		userConfig, err := db.GetUserInfo()
		exitOnErr(err)
		uuid := helpers.UuidV4()

		client = &chlib.Client{
			ApiHandler:    &chlib.HttpApiHandler{Config: &apiConfig, UserInfo: &userConfig, Np: np, Channel: uuid},
			TcpApiHandler: &chlib.TcpApiHandler{Config: &tcpApiConfig, UserInfo: &userConfig, Np: np, Channel: uuid},
			UserConfig:    &userConfig,
		}
		exitOnErr(db.Close())
	},
	Run: func(cmd *cobra.Command, args []string) {
		if cmd.Flags().NFlag() == 0 {
			cmd.Usage()
		}
	},
	BashCompletionFunction: bashCompletionFunc,
}

RootCmd main cmd entrypoint

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL