Skip to content
Snippets Groups Projects
Commit 892200eb authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Merge branch 'hotfix/CmdFlags' into 'release'

Have all viper.Get calls use cmd flag constants

See merge request !281
parents a65ba4b6 01aad324
Branches
Tags
2 merge requests!510Release,!281Have all viper.Get calls use cmd flag constants
......@@ -30,7 +30,7 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
// create a new client if none exist
if _, err := os.Stat(storeDir); errors.Is(err, fs.ErrNotExist) {
// Initialize from scratch
ndfJson, err := ioutil.ReadFile(viper.GetString("ndf"))
ndfJson, err := ioutil.ReadFile(viper.GetString(ndfFlag))
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
......@@ -44,7 +44,7 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
}
// Write the backup JSON to file
err = utils.WriteFileDef(viper.GetString("backupJsonOut"), backupJson)
err = utils.WriteFileDef(viper.GetString(backupJsonOutFlag), backupJson)
if err != nil {
jww.FATAL.Panicf("Failed to write backup to file: %+v", err)
}
......@@ -56,7 +56,7 @@ func loadOrInitBackup(backupPath string, backupPass string, password []byte, sto
jww.FATAL.Panicf("%+v", err)
}
backupIdListPath := viper.GetString("backupIdList")
backupIdListPath := viper.GetString(backupIdListFlag)
if backupIdListPath != "" {
// Marshal backed up ID list to JSON
backedUpIdListJson, err := json.Marshal(backupIdList)
......
......@@ -27,7 +27,7 @@ var broadcastCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cmixParams, e2eParams := initParams()
authCbs := makeAuthCallbacks(
viper.GetBool("unsafe-channel-creation"), e2eParams)
viper.GetBool(unsafeChannelCreationFlag), e2eParams)
client := initE2e(cmixParams, e2eParams, authCbs)
// Write user contact to file
......@@ -148,8 +148,8 @@ var broadcastCmd = &cobra.Command{
/* Broadcast client setup */
// Select broadcast method
symmetric := viper.GetString("symmetric")
asymmetric := viper.GetString("asymmetric")
symmetric := viper.GetString(broadcastSymmetricFlag)
asymmetric := viper.GetString(broadcastAsymmetricFlag)
// Connect to broadcast channel
bcl, err := broadcast.NewBroadcastChannel(*channel, client.GetCmix(), client.GetRng())
......@@ -187,7 +187,7 @@ var broadcastCmd = &cobra.Command{
go func() {
jww.INFO.Printf("Attempting to send broadcasts...")
sendDelay := time.Duration(viper.GetUint("sendDelay"))
sendDelay := time.Duration(viper.GetUint(sendDelayFlag))
maxRetries := 10
retries := 0
for {
......
......@@ -34,7 +34,7 @@ var dumpRoundsCmd = &cobra.Command{
cmixParams, e2eParams := initParams()
authCbs := makeAuthCallbacks(
viper.GetBool("unsafe-channel-creation"), e2eParams)
viper.GetBool(unsafeChannelCreationFlag), e2eParams)
client := initE2e(cmixParams, e2eParams, authCbs)
err := client.StartNetworkFollower(5 * time.Second)
if err != nil {
......
......@@ -37,7 +37,7 @@ var ftCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cmixParams, e2eParams := initParams()
authCbs := makeAuthCallbacks(
viper.GetBool("unsafe-channel-creation"), e2eParams)
viper.GetBool(unsafeChannelCreationFlag), e2eParams)
client := initE2e(cmixParams, e2eParams, authCbs)
// Print user's reception ID and save contact file
......
......@@ -36,7 +36,7 @@ var groupCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cmixParams, e2eParams := initParams()
authCbs := makeAuthCallbacks(
viper.GetBool("unsafe-channel-creation"), e2eParams)
viper.GetBool(unsafeChannelCreationFlag), e2eParams)
client := initE2e(cmixParams, e2eParams, authCbs)
// Print user's reception ID
......
......@@ -29,12 +29,12 @@ var initCmd = &cobra.Command{
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
// TODO: Handle userid-prefix argument
storePassword := parsePassword(viper.GetString("password"))
storeDir := viper.GetString("session")
regCode := viper.GetString("regcode")
storePassword := parsePassword(viper.GetString(passwordFlag))
storeDir := viper.GetString(sessionFlag)
regCode := viper.GetString(regCodeFlag)
// Initialize from scratch
ndfJson, err := ioutil.ReadFile(viper.GetString("ndf"))
ndfJson, err := ioutil.ReadFile(viper.GetString(ndfFlag))
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
......@@ -78,7 +78,7 @@ func loadOrInitCmix(password []byte, storeDir, regCode string,
// create a new client if none exist
if _, err := os.Stat(storeDir); errors.Is(err, fs.ErrNotExist) {
// Initialize from scratch
ndfJson, err := ioutil.ReadFile(viper.GetString("ndf"))
ndfJson, err := ioutil.ReadFile(viper.GetString(ndfFlag))
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
......@@ -162,7 +162,7 @@ func loadOrInitVanity(password []byte, storeDir, regCode, userIdPrefix string,
// create a new client if none exist
if _, err := os.Stat(storeDir); errors.Is(err, fs.ErrNotExist) {
// Initialize from scratch
ndfJson, err := ioutil.ReadFile(viper.GetString("ndf"))
ndfJson, err := ioutil.ReadFile(viper.GetString(ndfFlag))
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
......
......@@ -70,7 +70,7 @@ var rootCmd = &cobra.Command{
cmixParams, e2eParams := initParams()
authCbs := makeAuthCallbacks(
viper.GetBool("unsafe-channel-creation"), e2eParams)
viper.GetBool(unsafeChannelCreationFlag), e2eParams)
client := initE2e(cmixParams, e2eParams, authCbs)
jww.INFO.Printf("Client Initialized...")
......
......@@ -35,7 +35,7 @@ var singleCmd = &cobra.Command{
cmixParams, e2eParams := initParams()
authCbs := makeAuthCallbacks(
viper.GetBool("unsafe-channel-creation"), e2eParams)
viper.GetBool(unsafeChannelCreationFlag), e2eParams)
client := initE2e(cmixParams, e2eParams, authCbs)
// Write user contact to file
......
......@@ -36,7 +36,7 @@ var udCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cmixParams, e2eParams := initParams()
authCbs := makeAuthCallbacks(
viper.GetBool("unsafe-channel-creation"), e2eParams)
viper.GetBool(unsafeChannelCreationFlag), e2eParams)
client := initE2e(cmixParams, e2eParams, authCbs)
// get user and save contact to file
......@@ -63,7 +63,7 @@ var udCmd = &cobra.Command{
// Make user discovery manager
rng := client.GetRng()
userToRegister := viper.GetString("register")
userToRegister := viper.GetString(udRegisterFlag)
jww.TRACE.Printf("[UD] Registering user %v...", userToRegister)
userDiscoveryMgr, err := ud.NewManager(client, client.GetComms(),
client.NetworkFollowerStatus, userToRegister, nil)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment