// config defines the configuration options for findcheckpoint.
//
// See loadConfig for details on the configuration load process.
typeconfigstruct{
DataDirstring`short:"b" long:"datadir" description:"Location of the btcd data directory"`
NumCandidatesint`short:"n" long:"numcandidates" description:"Max num of checkpoint candidates to show {1-20}"`
UseGoOutputbool`short:"g" long:"gooutput" description:"Display the candidates using Go syntax that is ready to insert into the btcchain checkpoint list"`
}
// btcdHomeDir returns an OS appropriate home directory for btcd.
funcbtcdHomeDir()string{
// Search for Windows APPDATA first. This won't exist on POSIX OSes.
appData:=os.Getenv("APPDATA")
ifappData!=""{
returnfilepath.Join(appData,"btcd")
}
// Fall back to standard HOME directory that works for most POSIX OSes.
home:=os.Getenv("HOME")
ifhome!=""{
returnfilepath.Join(home,".btcd")
}
// In the worst case, use the current directory.
return"."
}
// loadConfig initializes and parses the config using command line options.
//
// The configuration proceeds as follows:
// 1) Start with a default config with sane settings
// 2) Pre-parse the command line to check for an alternative config file
// 3) Load configuration file overwriting defaults with any specified options
// 4) Parse CLI options and overwrite/add any specified options
//
// The above results in btcd functioning properly without any config settings
// while still allowing the user to override settings with config files and
// command line options. Command line options always take precedence.