Skip to content
Snippets Groups Projects
Commit e854abef authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Update client commands to add user discovery

parent d7949071
No related branches found
No related tags found
No related merge requests found
...@@ -519,30 +519,33 @@ func init() { ...@@ -519,30 +519,33 @@ func init() {
// Here you will define your flags and configuration settings. // Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here, // Cobra supports persistent flags, which, if defined here,
// will be global for your application. // will be global for your application.
rootCmd.Flags().BoolP("verbose", "v", false, rootCmd.PersistentFlags().BoolP("verbose", "v", false,
"Verbose mode for debugging") "Verbose mode for debugging")
viper.BindPFlag("verbose", rootCmd.Flags().Lookup("verbose")) viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
rootCmd.Flags().StringP("session", "s", rootCmd.PersistentFlags().StringP("session", "s",
"", "Sets the initial username and the directory for "+ "", "Sets the initial storage directory for "+
"client storage") "client session data")
viper.BindPFlag("session", rootCmd.Flags().Lookup("session")) viper.BindPFlag("session", rootCmd.PersistentFlags().Lookup("session"))
rootCmd.Flags().StringP("writeContact", "w", rootCmd.PersistentFlags().StringP("writeContact", "w",
"", "Write the contact file for this user to this file") "-", "Write contact information, if any, to this file, "+
viper.BindPFlag("writeContact", rootCmd.Flags().Lookup("writeContact")) " defaults to stdout")
viper.BindPFlag("writeContact", rootCmd.PersistentFlags().Lookup(
"writeContact"))
rootCmd.Flags().StringP("password", "p", "", rootCmd.PersistentFlags().StringP("password", "p", "",
"Password to the session file") "Password to the session file")
viper.BindPFlag("password", rootCmd.Flags().Lookup("password")) viper.BindPFlag("password", rootCmd.PersistentFlags().Lookup(
"password"))
rootCmd.Flags().StringP("ndf", "n", "ndf.json", rootCmd.PersistentFlags().StringP("ndf", "n", "ndf.json",
"Path to the network definition JSON file") "Path to the network definition JSON file")
viper.BindPFlag("ndf", rootCmd.Flags().Lookup("ndf")) viper.BindPFlag("ndf", rootCmd.PersistentFlags().Lookup("ndf"))
rootCmd.Flags().StringP("log", "l", "-", rootCmd.PersistentFlags().StringP("log", "l", "-",
"Path to the log output path (- is stdout)") "Path to the log output path (- is stdout)")
viper.BindPFlag("log", rootCmd.Flags().Lookup("log")) viper.BindPFlag("log", rootCmd.PersistentFlags().Lookup("log"))
rootCmd.Flags().StringP("regcode", "", "", rootCmd.Flags().StringP("regcode", "", "",
"Registration code (optional)") "Registration code (optional)")
...@@ -593,21 +596,6 @@ func init() { ...@@ -593,21 +596,6 @@ func init() {
"Accept the channel request for the corresponding recipient ID") "Accept the channel request for the corresponding recipient ID")
viper.BindPFlag("accept-channel", viper.BindPFlag("accept-channel",
rootCmd.Flags().Lookup("accept-channel")) rootCmd.Flags().Lookup("accept-channel"))
// Cobra also supports local flags, which will only run
// when this action is called directly.
// rootCmd.Flags().StringVarP(&notificationToken, "nbRegistration", "x", "",
// "Token to register user with notification bot")
// rootCmd.PersistentFlags().BoolVarP(&end2end, "end2end", "", false,
// "Send messages with E2E encryption to destination user. Must have found each other via UDB first")
// rootCmd.PersistentFlags().StringSliceVarP(&keyParams, "keyParams", "",
// make([]string, 0), "Define key generation parameters. Pass values in comma separated list"+
// " in the following order: MinKeys,MaxKeys,NumRekeys,TTLScalar,MinNumKeys")
// rootCmd.Flags().StringVarP(&searchForUser, "SearchForUser", "s", "",
// "Sets the email to search for to find a user with user discovery")
} }
// initConfig reads in config file and ENV variables if set. // initConfig reads in config file and ENV variables if set.
......
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
// Package cmd initializes the CLI and config parsers as well as the logger.
package cmd
import (
"github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
)
// udCmd user discovery subcommand, allowing user lookup and registration for
// allowing others to search.
// This basically runs a client for these functions with the UD module enabled.
// Normally, clients don't need it so it is not loaded for the rest of the
// commands.
var udCmd = &cobra.Command{
Use: "ud",
Short: ("Register for & search users using the xxnet user discovery " +
"service"),
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
// UD Command does nothing right now.
jww.INFO.Printf("Hello, World")
},
}
func init() {
// User Discovery subcommand Options
udCmd.Flags().StringP("register", "r", "",
"Register this user with user discovery")
viper.BindPFlag("register",
udCmd.Flags().Lookup("register"))
udCmd.Flags().StringP("addphone", "", "",
"Add phone number to existing user registration.")
viper.BindPFlag("addphone", udCmd.Flags().Lookup("addphone"))
udCmd.Flags().StringP("addemail", "e", "",
"Add email to existing user registration.")
viper.BindPFlag("addemail", udCmd.Flags().Lookup("addemail"))
udCmd.Flags().StringP("lookup", "u", "",
"Look up user ID. Use '0x' or 'b64:' for hex and base64 "+
"representations")
viper.BindPFlag("lookup", udCmd.Flags().Lookup("lookup"))
udCmd.Flags().StringP("searchusername", "", "",
"Search for users with this username")
viper.BindPFlag("searchusername",
udCmd.Flags().Lookup("searchusername"))
udCmd.Flags().StringP("searchemail", "", "",
"Search for users with this email address")
viper.BindPFlag("searchemail",
udCmd.Flags().Lookup("searchemail"))
udCmd.Flags().StringP("searchphone", "", "",
"Search for users with this email address")
viper.BindPFlag("searchphone",
udCmd.Flags().Lookup("searchphone"))
rootCmd.AddCommand(udCmd)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment