Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpcs
dfss
Commits
101a357a
Commit
101a357a
authored
May 25, 2016
by
Loïck Bonniot
Browse files
Merge branch 'fix_13_verbose_flag' into 'master'
[demo] Verbose flag print DLog to stdout Should fix
#13
See merge request
!88
parents
2f3b6c55
64ba9b13
Pipeline
#2204
passed with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dfssc/cmd/root.go
View file @
101a357a
...
...
@@ -24,7 +24,7 @@ A tool to sign multiparty contract using a secure cryptographic protocol`,
},
PersistentPreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
net
.
DefaultTimeout
=
viper
.
GetDuration
(
"timeout"
)
dapi
.
Configure
(
viper
.
GetString
(
"demo"
)
!=
""
,
viper
.
GetString
(
"demo"
),
"client"
)
dapi
.
Configure
(
viper
.
GetBool
(
"verbose"
),
viper
.
GetString
(
"demo"
)
!=
""
,
viper
.
GetString
(
"demo"
),
"client"
)
},
PersistentPostRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
dapi
.
DClose
()
...
...
dfssd/api/client.go
View file @
101a357a
package
api
import
(
"fmt"
"time"
"golang.org/x/net/context"
...
...
@@ -10,7 +11,7 @@ import (
var
(
address
,
identifier
string
demo
bool
demo
,
verbose
bool
// lazy initializer
dial
*
grpc
.
ClientConn
demoClient
DemonstratorClient
...
...
@@ -18,10 +19,11 @@ var (
// Configure is used to update current parameters.
// Call it at least one time before the first DLog call.
func
Configure
(
activated
bool
,
addrport
,
id
string
)
{
func
Configure
(
verbswitch
,
activated
bool
,
addrport
,
id
string
)
{
address
=
addrport
identifier
=
id
demo
=
activated
verbose
=
verbswitch
}
// SetIdentifier updates the current client identifier.
...
...
@@ -58,6 +60,11 @@ func DClose() {
//
// The client is dialed in a lazy way
func
DLog
(
log
string
)
{
// check verbose switch
if
verbose
{
fmt
.
Println
(
log
)
}
// check demo switch
if
!
demo
{
return
...
...
dfssp/cmd/root.go
View file @
101a357a
...
...
@@ -20,7 +20,7 @@ Users and Contracts manager`,
_
=
cmd
.
Help
()
},
PersistentPreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
dapi
.
Configure
(
viper
.
GetString
(
"demo"
)
!=
""
,
viper
.
GetString
(
"demo"
),
"platform"
)
dapi
.
Configure
(
viper
.
GetBool
(
"verbose"
),
viper
.
GetString
(
"demo"
)
!=
""
,
viper
.
GetString
(
"demo"
),
"platform"
)
},
PersistentPostRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
dapi
.
DClose
()
...
...
dfsst/cmd/root.go
View file @
101a357a
...
...
@@ -5,6 +5,7 @@ import (
"fmt"
"dfss"
dapi
"dfss/dfssd/api"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
...
...
@@ -22,6 +23,12 @@ Sign your contract using a secure cryptographic protocol`,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
_
=
cmd
.
Help
()
},
PersistentPreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
dapi
.
Configure
(
viper
.
GetBool
(
"verbose"
),
viper
.
GetString
(
"demo"
)
!=
""
,
viper
.
GetString
(
"demo"
),
"ttp"
)
},
PersistentPostRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
dapi
.
DClose
()
},
}
// All of the flags will be gathered by viper, this is why
...
...
dfsst/cmd/start.go
View file @
101a357a
...
...
@@ -20,9 +20,6 @@ var startCmd = &cobra.Command{
Fill the DFSS_TTP_PASSWORD environment variable if the private key is enciphered`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
demo
:=
viper
.
GetString
(
"demo"
)
dapi
.
Configure
(
demo
!=
""
,
demo
,
"ttp"
)
srv
:=
server
.
GetServer
()
addrPort
:=
viper
.
GetString
(
"address"
)
+
":"
+
strconv
.
Itoa
(
viper
.
GetInt
(
"port"
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment