-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cmd * add Makfile
- Loading branch information
Showing
7 changed files
with
616 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
all: install | ||
|
||
LD_FLAGS = -w -s | ||
|
||
|
||
BUILD_FLAGS := -ldflags '$(LD_FLAGS)' | ||
|
||
build: | ||
@echo "Building subnode" | ||
@go build -mod readonly $(BUILD_FLAGS) -o build/subnode main.go | ||
|
||
install: | ||
@echo "Installing subnode" | ||
@go install -mod readonly $(BUILD_FLAGS) ./... | ||
|
||
clean: | ||
rm -rf build | ||
|
||
.PHONY: all lint test race msan tools clean build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var ( | ||
configFile string | ||
) | ||
|
||
// NewRootCmd returns the root command | ||
func NewRootCmd() *cobra.Command { | ||
// RootCmd represents the base command when called without any subcommands | ||
var rootCmd = &cobra.Command{ | ||
Use: "subnode", | ||
Short: "subnode is a smart reverse proxy server for cosmos based chains", | ||
} | ||
|
||
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error { | ||
// reads `subnode.yaml` into `var config *Config` before each command | ||
// if err := initConfig(rootCmd); err != nil { | ||
// return err | ||
// } | ||
|
||
return nil | ||
} | ||
|
||
// --app flag | ||
rootCmd.PersistentFlags().StringVar(&configFile, "config-file", "subnode.yaml", "path to the config file") | ||
if err := viper.BindPFlag("config-file", rootCmd.PersistentFlags().Lookup("config-file")); err != nil { | ||
panic(err) | ||
} | ||
|
||
rootCmd.AddCommand( | ||
startCmd(), | ||
) | ||
|
||
return rootCmd | ||
} | ||
|
||
// 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.EnableCommandSorting = false | ||
|
||
rootCmd := NewRootCmd() | ||
rootCmd.SilenceUsage = true | ||
rootCmd.CompletionOptions.DisableDefaultCmd = true | ||
|
||
if err := rootCmd.Execute(); err != nil { | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func startCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "start", | ||
Short: "start subnode server", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
|
||
fmt.Println("startCmd") | ||
|
||
return nil | ||
}, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module github.com/notional-labs/subnode | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/spf13/cobra v1.6.1 | ||
github.com/spf13/viper v1.15.0 | ||
) | ||
|
||
require ( | ||
github.com/fsnotify/fsnotify v1.6.0 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.1 // indirect | ||
github.com/magiconair/properties v1.8.7 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect | ||
github.com/spf13/afero v1.9.3 // indirect | ||
github.com/spf13/cast v1.5.0 // indirect | ||
github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/subosito/gotenv v1.4.2 // indirect | ||
golang.org/x/sys v0.3.0 // indirect | ||
golang.org/x/text v0.5.0 // indirect | ||
gopkg.in/ini.v1 v1.67.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/notional-labs/subnode/cmd" | ||
) | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |