Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli-v2s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
clients
Rust
Ğcli-v2s
Commits
4abc16e7
Commit
4abc16e7
authored
1 year ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
implement config formatter
parent
bea7e02e
No related branches found
No related tags found
1 merge request
!11
refac call submission and event watch
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+6
-0
6 additions, 0 deletions
README.md
src/conf.rs
+20
-1
20 additions, 1 deletion
src/conf.rs
with
26 additions
and
1 deletion
README.md
+
6
−
0
View file @
4abc16e7
...
...
@@ -66,3 +66,9 @@ Secret and/or public keys can always be passed using `--secret` and `--address`.
Secret key format can be changed using
`--secret-format`
with the following values:
*
`substrate`
: a Substrate secret address (optionally followed by a derivation path), or BIP39 mnemonic
*
`seed`
: a 32-bytes seed in hexadecimal (Duniter v1 compatible)
## TODO
-
[x] implement config formatter
-
[ ] add link/unlink account commands
-
[ ] migrate all xt to submit_call_and_look_event
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/conf.rs
+
20
−
1
View file @
4abc16e7
...
...
@@ -27,6 +27,25 @@ impl std::default::Default for Config {
}
}
impl
std
::
fmt
::
Display
for
Config
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
let
secret
=
if
self
.secret
.is_some
()
{
"(secret defined)"
}
else
{
"(no secret)"
};
let
address
=
if
let
Some
(
address
)
=
&
self
.address
{
format!
(
"{}"
,
address
)
}
else
{
"(no address)"
.to_string
()
};
writeln!
(
f
,
"Ğcli config"
)
?
;
writeln!
(
f
,
"duniter endpoint {}"
,
self
.duniter_endpoint
)
?
;
writeln!
(
f
,
"indexer endpoint {}"
,
self
.indexer_endpoint
)
?
;
write!
(
f
,
"address {address} {secret}"
)
}
}
/// load config file and manage error if could not
pub
fn
load_conf
()
->
Config
{
match
confy
::
load
(
APP_NAME
,
None
)
{
...
...
@@ -68,7 +87,7 @@ pub fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<()> {
);
}
Subcommand
::
Show
=>
{
println!
(
"{
:?
}"
,
data
.cfg
);
println!
(
"{}"
,
data
.cfg
);
}
Subcommand
::
Save
=>
{
confy
::
store
(
APP_NAME
,
None
,
&
data
.cfg
)
.expect
(
"unable to write config"
);
...
...
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