This will eventually be rolled into hush lightwalletd but this repo is separate for now
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

80 lines
2.2 KiB

// Copyright 2021 Jahway603 & The Hush developers
// Released under the GPLv3
// Living that Highd life!
package cmd
import (
//"context"
"fmt"
//"net"
"os"
//"os/signal"
//"syscall"
//"time"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
//"google.golang.org/grpc"
//"google.golang.org/grpc/credentials"
//"google.golang.org/grpc/peer"
//"google.golang.org/grpc/reflection"
)
var cfgFile string
var log *logrus.Entry
var logger = logrus.New()
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "highlited",
Short: "The high life version of Hush lightwalletd",
Long: `I am exploring Golang and this is a testbed to add
new features to Hush lightwalletd.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Welcome to Hush HightLightd...")
//opts := &common.Options{
// GRPCBindAddr: viper.GetString("grpc-bind-addr"),
//}
},
}
// Execute adds all child commands to root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
cobra.CheckErr(rootCmd.Execute())
}
func init() {
rootCmd.AddCommand(versionCmd)
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is the file .highlited in the current directory)")
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().String("grpc-bind-addr", "127.0.0.1:9067", "the address to listen for grpc on")
viper.BindPFlag("grpc-bind-addr", rootCmd.Flags().Lookup("grpc-bind-addr"))
viper.SetDefault("grpc-bind-addr", "127.0.0.1:9067")
}
// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Look in the current directory for a configuration file
viper.AddConfigPath(".")
viper.SetConfigName(".highlited")
}
viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
}