lnd.xprv/cmd/lnd/main.go
Oliver Gugger 7158103d4d
lnd+config: move config parsing to cmd
Now that we have access to the configuration parsing outside of the
main package, we can move the actual parsing to the command line
package.
2020-05-14 14:37:51 +02:00

30 lines
684 B
Go

package main
import (
"fmt"
"os"
flags "github.com/jessevdk/go-flags"
"github.com/lightningnetwork/lnd"
)
func main() {
// Load the configuration, and parse any command line options. This
// function will also set up logging properly.
loadedConfig, err := lnd.LoadConfig()
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
// Call the "real" main in a nested manner so the defers will properly
// be executed in the case of a graceful shutdown.
if err := lnd.Main(loadedConfig, lnd.ListenerCfg{}); err != nil {
if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {
} else {
_, _ = fmt.Fprintln(os.Stderr, err)
}
os.Exit(1)
}
}