mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-05 13:46:42 +00:00

* [NOD-102] Change mining simulator to work with cli arguments and add DisableTLS option * [NOD-102] Add config.go * [NOD-102] Change config missing aruments errors
34 lines
840 B
Go
34 lines
840 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/jessevdk/go-flags"
|
|
)
|
|
|
|
type config struct {
|
|
AddressListPath string `long:"addresslist" description:"Path to a list of nodes' JSON-RPC endpoints" required:"true"`
|
|
CertificatePath string `long:"cert" description:"Path to certificate accepted by JSON-RPC endpoint"`
|
|
DisableTLS bool `long:"notls" description:"Disable TLS"`
|
|
}
|
|
|
|
func parseConfig() (*config, error) {
|
|
cfg := &config{}
|
|
parser := flags.NewParser(cfg, flags.PrintErrors|flags.HelpFlag)
|
|
_, err := parser.Parse()
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if cfg.CertificatePath == "" && !cfg.DisableTLS {
|
|
return nil, errors.New("--notls has to be disabled if --cert is used")
|
|
}
|
|
|
|
if cfg.CertificatePath != "" && cfg.DisableTLS {
|
|
return nil, errors.New("--cert should be omitted if --notls is used")
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|