File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 260113 .0
1+ 260120 .0
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ mod client;
1010mod key;
1111mod maintenance;
1212mod node;
13+ mod rename;
1314mod test_client;
1415mod test_server;
1516mod view;
@@ -29,6 +30,9 @@ enum Command {
2930 /// Get overview of your Node Operator
3031 View ( ClusterArgs ) ,
3132
33+ /// Change the name of your Node Operator
34+ Rename ( rename:: Args ) ,
35+
3236 /// Key management
3337 #[ command( subcommand) ]
3438 Key ( key:: Command ) ,
@@ -103,6 +107,7 @@ async fn main() -> anyhow::Result<()> {
103107
104108 match cli. command {
105109 Command :: View ( args) => view:: execute ( args) . await ?,
110+ Command :: Rename ( args) => rename:: execute ( args) . await ?,
106111 Command :: Key ( cmd) => key:: execute ( cmd) ,
107112 Command :: Node ( cmd) => node:: execute ( cmd) . await ?,
108113 Command :: Client ( cmd) => client:: execute ( cmd) . await ?,
Original file line number Diff line number Diff line change 1+ use { crate :: ClusterArgs , anyhow:: Context , wcn_cluster:: node_operator} ;
2+
3+ #[ derive( Debug , clap:: Args ) ]
4+ pub ( super ) struct Args {
5+ #[ command( flatten) ]
6+ cluster_args : ClusterArgs ,
7+
8+ /// New name
9+ #[ arg( long, short) ]
10+ name : node_operator:: Name ,
11+
12+ /// Skip interactive approval of the changes before writing to the
13+ /// Smart-Contract.
14+ #[ arg( long) ]
15+ auto_approve : bool ,
16+ }
17+
18+ pub ( super ) async fn execute ( args : Args ) -> anyhow:: Result < ( ) > {
19+ let cluster = args. cluster_args . connect ( ) . await ?;
20+ let mut operator = crate :: current_operator ( & cluster) ?;
21+
22+ println ! ( "Current name: {}" , operator. name) ;
23+ println ! ( "New name: {}" , args. name) ;
24+
25+ operator. name = args. name ;
26+
27+ if args. auto_approve || crate :: ask_approval ( ) ? {
28+ cluster
29+ . update_node_operator ( operator)
30+ . await
31+ . context ( "Cluster::update_node_operator" ) ?;
32+ }
33+
34+ Ok ( ( ) )
35+ }
You can’t perform that action at this time.
0 commit comments