Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
e854abef
Commit
e854abef
authored
Dec 17, 2020
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Update client commands to add user discovery
parent
d7949071
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/root.go
+18
-30
18 additions, 30 deletions
cmd/root.go
cmd/ud.go
+64
-0
64 additions, 0 deletions
cmd/ud.go
with
82 additions
and
30 deletions
cmd/root.go
+
18
−
30
View file @
e854abef
...
@@ -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
.
Persistent
Flags
()
.
BoolP
(
"verbose"
,
"v"
,
false
,
"Verbose mode for debugging"
)
"Verbose mode for debugging"
)
viper
.
BindPFlag
(
"verbose"
,
rootCmd
.
Flags
()
.
Lookup
(
"verbose"
))
viper
.
BindPFlag
(
"verbose"
,
rootCmd
.
Persistent
Flags
()
.
Lookup
(
"verbose"
))
rootCmd
.
Flags
()
.
StringP
(
"session"
,
"s"
,
rootCmd
.
Persistent
Flags
()
.
StringP
(
"session"
,
"s"
,
""
,
"Sets the initial
username and th
e directory for "
+
""
,
"Sets the initial
storag
e directory for "
+
"client s
torage
"
)
"client s
ession data
"
)
viper
.
BindPFlag
(
"session"
,
rootCmd
.
Flags
()
.
Lookup
(
"session"
))
viper
.
BindPFlag
(
"session"
,
rootCmd
.
Persistent
Flags
()
.
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
.
Persistent
Flags
()
.
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
.
Persistent
Flags
()
.
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
.
Persistent
Flags
()
.
Lookup
(
"ndf"
))
rootCmd
.
Flags
()
.
StringP
(
"log"
,
"l"
,
"-"
,
rootCmd
.
Persistent
Flags
()
.
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
.
Persistent
Flags
()
.
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(¬ificationToken, "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.
...
...
This diff is collapsed.
Click to expand it.
cmd/ud.go
0 → 100644
+
64
−
0
View file @
e854abef
///////////////////////////////////////////////////////////////////////////////
// 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
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment