From bf37e8aa3772598b71a12c0a018c737c2492ed34 Mon Sep 17 00:00:00 2001 From: joshemb <josh@elixxir.io> Date: Tue, 23 Aug 2022 16:30:06 -0700 Subject: [PATCH] Resolve comments --- cmd/flags.go | 2 +- cmd/init.go | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cmd/flags.go b/cmd/flags.go index 9efa8b352..edd40259a 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -82,7 +82,7 @@ const ( profileCpuFlag = "profile-cpu" profileMemFlag = "profile-mem" userIdPrefixFlag = "userid-prefix" - setLegacyFlag = "setLegacy" + legacyFlag = "legacy" ///////////////// Broadcast subcommand flags ////////////////////////////// broadcastNameFlag = "name" diff --git a/cmd/init.go b/cmd/init.go index a7a73b11b..62b56daf9 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -45,24 +45,27 @@ var initCmd = &cobra.Command{ jww.FATAL.Panicf("%+v", err) } + // Generate identity var identity xxdk.ReceptionIdentity - if viper.GetBool(setLegacyFlag) { + if viper.GetBool(legacyFlag) { identity, err = xxdk.MakeLegacyReceptionIdentity(net) - if err != nil { - jww.FATAL.Panicf("%+v", err) - } } else { identity, err = xxdk.MakeReceptionIdentity(net) - if err != nil { - jww.FATAL.Panicf("%+v", err) - } + + } + + // Panic if conditional branch fails + if err != nil { + jww.FATAL.Panicf("%+v", err) } + // Store identity err = xxdk.StoreReceptionIdentity(identityStorageKey, identity, net) if err != nil { jww.FATAL.Panicf("%+v", err) } + // Write contact to file jww.INFO.Printf("User: %s", identity.ID) writeContact(identity.GetContact()) @@ -76,9 +79,9 @@ func init() { "Desired prefix of userID to brute force when running init command. Prepend (?i) for case-insensitive. Only Base64 characters are valid.") bindFlagHelper(userIdPrefixFlag, initCmd) - initCmd.Flags().BoolP(setLegacyFlag, "", false, - "Generates a legacy contact file if set. Otherwise generates a standard contact file.") - bindFlagHelper(setLegacyFlag, initCmd) + initCmd.Flags().BoolP(legacyFlag, "", false, + "Generates a legacy identity if set. Otherwise generates a standard contact file.") + bindFlagHelper(legacyFlag, initCmd) rootCmd.AddCommand(initCmd) } -- GitLab