From 520841070e872d5ef7ce117b7ed92dfd8f655d91 Mon Sep 17 00:00:00 2001 From: Jim Pick Date: Mon, 22 Apr 2024 19:11:38 +0000 Subject: [PATCH] Create .glif/config.toml with defaults if it doesn't exist --- cmd/root.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index b271666..1ea4782 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -137,8 +137,10 @@ func initConfig() { if errors.Is(err, fs.ErrNotExist) { logFatalf("No config file found at %s\n", viper.ConfigFileUsed()) } else if _, ok := err.(viper.ConfigFileNotFoundError); ok { - // Config file not found; ignore error if desired - fmt.Fprintln(os.Stderr, "Warning: No config file found.") + // No .glif/config.toml, populate with mainnet defaults + viper.Set("daemon.rpc-url", deploy.Extern.LotusDialAddr) + viper.Set("daemon.token", "") + viper.SafeWriteConfig() } else { logFatalf("Config file error: %v\n", err) }