mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-08-22 18:43:15 +00:00

* [NOD-386] Extract net parsing functionality to a shared place. * [NOD-386] Add extract ActiveNetParams to cmdconfig * [NOD-386] Adding comments so go-vet won't shout at me * [NOD-386] Rename package name to config * [NOD-386] Rename commandConfig to configFlags * [NOD-386] Rename function to ResolveNetwork * [NOD-386] Fix renaming errors * [NOD-386] Refactor network config to btcd level so APIserver and btcd could use it * [NOD-386] Refactor network config to config package * [NOD-386] Move ActiveNetParams to network section * [NOD-386] Explictly return nil * [NOD-386] Reuse activeNetParams from netwrok config * [NOD-386] Set ActiveNetworkFlags instance to be global * [NOD-386] Remove redundant newline * [NOD-386] Init ActiveNetParams in address manager test * [NOD-386] Add dnsseeder network config * [NOD-386] Use ActiveConfig() method to access configuration
37 lines
899 B
Go
37 lines
899 B
Go
package main
|
|
|
|
import (
|
|
"github.com/daglabs/btcd/config"
|
|
"github.com/jessevdk/go-flags"
|
|
)
|
|
|
|
var activeConfig *ConfigFlags
|
|
|
|
// ActiveConfig returns the active configuration struct
|
|
func ActiveConfig() *ConfigFlags {
|
|
return activeConfig
|
|
}
|
|
|
|
// ConfigFlags holds the configurations set by the command line argument
|
|
type ConfigFlags struct {
|
|
Transaction string `long:"transaction" short:"t" description:"Unsigned transaction in HEX format" required:"true"`
|
|
PrivateKey string `long:"private-key" short:"p" description:"Private key" required:"true"`
|
|
config.NetworkFlags
|
|
}
|
|
|
|
func parseCommandLine() (*ConfigFlags, error) {
|
|
activeConfig = &ConfigFlags{}
|
|
parser := flags.NewParser(activeConfig, flags.PrintErrors|flags.HelpFlag)
|
|
_, err := parser.Parse()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = activeConfig.ResolveNetwork(parser)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return activeConfig, nil
|
|
}
|