Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
36dca42e
Commit
36dca42e
authored
5 years ago
by
dvermd
Browse files
Options
Downloads
Patches
Plain Diff
[fix] core:commands:
#108
rework keys cli options
parent
7d6a36b4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.lock
+1
-0
1 addition, 0 deletions
Cargo.lock
lib/core/core/Cargo.toml
+3
-0
3 additions, 0 deletions
lib/core/core/Cargo.toml
lib/core/core/src/commands/keys.rs
+47
-13
47 additions, 13 deletions
lib/core/core/src/commands/keys.rs
with
51 additions
and
13 deletions
Cargo.lock
+
1
−
0
View file @
36dca42e
...
@@ -1031,6 +1031,7 @@ name = "durs-core"
...
@@ -1031,6 +1031,7 @@ name = "durs-core"
version = "0.3.0-dev"
version = "0.3.0-dev"
dependencies = [
dependencies = [
"chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dubp-currency-params 0.2.0",
"dubp-currency-params 0.2.0",
...
...
This diff is collapsed.
Click to expand it.
lib/core/core/Cargo.toml
+
3
−
0
View file @
36dca42e
...
@@ -11,6 +11,7 @@ path = "src/lib.rs"
...
@@ -11,6 +11,7 @@ path = "src/lib.rs"
[dependencies]
[dependencies]
chrono
=
"0.4"
chrono
=
"0.4"
clap
=
"2.33.0"
clear_on_drop
=
"0.2.3"
clear_on_drop
=
"0.2.3"
dirs
=
"2.0.2"
dirs
=
"2.0.2"
durs-bc
=
{
path
=
"../../modules/blockchain/blockchain"
}
durs-bc
=
{
path
=
"../../modules/blockchain/blockchain"
}
...
@@ -31,6 +32,8 @@ serde = "1.0.*"
...
@@ -31,6 +32,8 @@ serde = "1.0.*"
serde_derive
=
"1.0.*"
serde_derive
=
"1.0.*"
serde_json
=
"1.0.*"
serde_json
=
"1.0.*"
structopt
=
"0.3.4"
structopt
=
"0.3.4"
#strum = "0.17.1"
#strum_macros = "0.17.1"
unwrap
=
"1.2.1"
unwrap
=
"1.2.1"
[features]
[features]
This diff is collapsed.
Click to expand it.
lib/core/core/src/commands/keys.rs
+
47
−
13
View file @
36dca42e
...
@@ -21,6 +21,8 @@ use crate::DursCore;
...
@@ -21,6 +21,8 @@ use crate::DursCore;
use
clear_on_drop
::
clear
::
Clear
;
use
clear_on_drop
::
clear
::
Clear
;
use
durs_conf
::
keys
::
*
;
use
durs_conf
::
keys
::
*
;
use
durs_conf
::
DuRsConf
;
use
durs_conf
::
DuRsConf
;
//use strum_macros::EnumString;
use
clap
::
arg_enum
;
#[derive(StructOpt,
Debug,
Clone)]
#[derive(StructOpt,
Debug,
Clone)]
#[structopt(
#[structopt(
...
@@ -90,21 +92,53 @@ pub enum ModifySubCommand {
...
@@ -90,21 +92,53 @@ pub enum ModifySubCommand {
/// Salt and password of network key
/// Salt and password of network key
NetworkSaltPassword
(
SaltPasswordOpt
),
NetworkSaltPassword
(
SaltPasswordOpt
),
}
}
/*
arg_enum! {
#[derive(StructOpt, Debug, Copy, Clone, PartialEq)]
/// Key to clear: member, network or all (both member and network)
enum ClearOpt {
MEMBER,
NETWORK,
ALL,
}
}
impl ClearOpt {
/// Returns if key kind is member
pub fn is_member(self) -> bool {
self == ClearOpt::MEMBER || self == ClearOpt::ALL
}
/// Returns if key kind is network
pub fn is_network(self) -> bool {
self == ClearOpt::NETWORK || self == ClearOpt::ALL
}
}*/
arg_enum!
{
/// KeyKind
#[derive(Debug,
Copy,
Clone,
PartialEq)]
enum
KeyKind
{
MEMBER
,
NETWORK
,
ALL
,
}
}
impl
KeyKind
{
/// Returns if key kind is member
pub
fn
is_member
(
self
)
->
bool
{
self
==
KeyKind
::
MEMBER
||
self
==
KeyKind
::
ALL
}
/// Returns if key kind is network
pub
fn
is_network
(
self
)
->
bool
{
self
==
KeyKind
::
NETWORK
||
self
==
KeyKind
::
ALL
}
}
#[derive(StructOpt,
Debug,
Copy,
Clone)]
#[derive(StructOpt,
Debug,
Copy,
Clone)]
/// ClearOpt
/// ClearOpt
pub
struct
ClearOpt
{
pub
struct
ClearOpt
{
#[structopt(short
=
"m"
,
long
=
"member"
)]
/// Key to clear
/// True if we change member key
#[structopt(possible_values
=
&
KeyKind::variants(),
case_insensitive
=
true
)]
pub
member
:
bool
,
key
:
KeyKind
,
#[structopt(short
=
"n"
,
long
=
"network"
)]
/// True if we change network key
pub
network
:
bool
,
#[structopt(short
=
"a"
,
long
=
"all"
)]
/// True if we change member and network key
pub
all
:
bool
,
}
}
#[derive(StructOpt,
Debug,
Clone)]
#[derive(StructOpt,
Debug,
Clone)]
...
@@ -169,8 +203,8 @@ impl DursExecutableCoreCommand for KeysOpt {
...
@@ -169,8 +203,8 @@ impl DursExecutableCoreCommand for KeysOpt {
},
},
KeysSubCommand
::
Clear
(
clear_opt
)
=>
{
KeysSubCommand
::
Clear
(
clear_opt
)
=>
{
let
new_keypairs
=
clear_keys
(
let
new_keypairs
=
clear_keys
(
clear_opt
.
network
||
clear_opt
.all
,
clear_opt
.
key
.is_network
()
,
clear_opt
.
member
||
clear_opt
.all
,
clear_opt
.
key
.is_member
()
,
keypairs
,
keypairs
,
);
);
save_keypairs
(
profile_path
,
&
keypairs_file
,
new_keypairs
)
save_keypairs
(
profile_path
,
&
keypairs_file
,
new_keypairs
)
...
...
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