jahway603
3 years ago
4 changed files with 107 additions and 1 deletions
@ -1,3 +1,7 @@ |
|||
# highlited |
|||
|
|||
This will eventually be rolled into hush lightwalletd but this repo is separate for now |
|||
This will eventually be rolled into hush lightwalletd but this repo is separate for now |
|||
|
|||
## License |
|||
|
|||
[GPLv3](LICENSE) |
|||
|
@ -0,0 +1,68 @@ |
|||
// Copyright 2021 Jahway603 & The Hush developers
|
|||
// Released under the GPLv3
|
|||
package cmd |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/spf13/cobra" |
|||
"github.com/spf13/viper" |
|||
"os" |
|||
) |
|||
|
|||
var cfgFile string |
|||
|
|||
// rootCmd represents the base command when called without any subcommands
|
|||
var rootCmd = &cobra.Command{ |
|||
Use: "highlited", |
|||
Short: "A 'high' version of Hush lightwalletd", |
|||
Long: `I am exploring Golang and this is a testbed to add |
|||
new features to Hush lightwalletd over the long term.`, |
|||
// Uncomment the following line if your bare application
|
|||
// has an action associated with it:
|
|||
Run: func(cmd *cobra.Command, args []string) { fmt.Println("Welcome to HightLigtD...") }, |
|||
} |
|||
|
|||
// 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() { |
|||
cobra.CheckErr(rootCmd.Execute()) |
|||
} |
|||
|
|||
func init() { |
|||
rootCmd.AddCommand(versionCmd) |
|||
cobra.OnInitialize(initConfig) |
|||
|
|||
// 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/.highlited.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") |
|||
} |
|||
|
|||
// initConfig reads in config file and ENV variables if set.
|
|||
func initConfig() { |
|||
if cfgFile != "" { |
|||
// Use config file from the flag.
|
|||
viper.SetConfigFile(cfgFile) |
|||
} else { |
|||
// Find home directory.
|
|||
home, err := os.UserHomeDir() |
|||
cobra.CheckErr(err) |
|||
|
|||
// Search config in home directory with name ".highlited" (without extension).
|
|||
viper.AddConfigPath(home) |
|||
viper.SetConfigType("yaml") |
|||
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()) |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
// Copyright 2021 Jahway603 & The Hush developers
|
|||
// Released under the GPLv3
|
|||
//
|
|||
// Package to show the Version
|
|||
package cmd |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/spf13/cobra" |
|||
) |
|||
|
|||
// versionCmd represents the version command
|
|||
var versionCmd = &cobra.Command{ |
|||
Use: "version", |
|||
Short: "Display highlightd version", |
|||
Long: `Display highlightd version as we get this cooking...`, |
|||
Run: func(cmd *cobra.Command, args []string) { |
|||
fmt.Println("hightlightd version: v0.1.0-alpha") |
|||
fmt.Println("hightlightd author: jahway603") |
|||
}, |
|||
} |
|||
|
|||
func init() { |
|||
rootCmd.AddCommand(versionCmd) |
|||
} |
@ -0,0 +1,9 @@ |
|||
// Copyright 2021 Jahway603 & The Hush developers
|
|||
// Released under the GPLv3
|
|||
package main |
|||
|
|||
import "git.hush.is/jahway603/highlited/cmd" |
|||
|
|||
func main() { |
|||
cmd.Execute() |
|||
} |
Loading…
Reference in new issue