@@ -4,15 +4,10 @@ use byte_unit::{Byte, Unit};
44use clap:: { ArgAction , Args } ;
55use ic_agent:: { AgentError , export:: Principal } ;
66use ic_management_canister_types:: { CanisterStatusResult , EnvironmentVariable , LogVisibility } ;
7- use icp:: {
8- agent,
9- identity:: { self , IdentitySelection } ,
10- network,
11- } ;
7+ use icp:: { agent, identity, network} ;
128
139use crate :: {
14- commands:: { Context , GetAgentForEnvError , GetCanisterIdForEnvError , GetEnvironmentError } ,
15- options:: { EnvironmentOpt , IdentityOpt } ,
10+ commands:: { Context , GetAgentForEnvError , GetCanisterIdForEnvError , GetEnvironmentError , args} ,
1611 store_id:: LookupError as LookupIdError ,
1712} ;
1813
@@ -78,14 +73,8 @@ impl EnvironmentVariableOpt {
7873
7974#[ derive( Debug , Args ) ]
8075pub ( crate ) struct UpdateArgs {
81- /// The name of the canister within the current project
82- pub ( crate ) name : String ,
83-
84- #[ command( flatten) ]
85- identity : IdentityOpt ,
86-
8776 #[ command( flatten) ]
88- environment : EnvironmentOpt ,
77+ pub ( crate ) cmd_args : args :: CanisterCommandArgs ,
8978
9079 #[ command( flatten) ]
9180 controllers : Option < ControllerOpt > ,
@@ -146,18 +135,13 @@ pub(crate) enum CommandError {
146135
147136 #[ error( transparent) ]
148137 GetCanisterIdForEnv ( #[ from] GetCanisterIdForEnvError ) ,
138+
139+ #[ error( transparent) ]
140+ Shared ( #[ from] args:: ArgValidationError ) ,
149141}
150142
151143pub ( crate ) async fn exec ( ctx : & Context , args : & UpdateArgs ) -> Result < ( ) , CommandError > {
152- let identity_selection: IdentitySelection = args. identity . clone ( ) . into ( ) ;
153- let environment = args. environment . name ( ) ;
154-
155- // Agent
156- let agent = ctx
157- . get_agent_for_env ( & identity_selection, environment)
158- . await ?;
159-
160- let cid = ctx. get_canister_id_for_env ( & args. name , environment) . await ?;
144+ let ( cid, agent) = args. cmd_args . get_cid_and_agent ( ctx) . await ?;
161145
162146 // Management Interface
163147 let mgmt = ic_utils:: interfaces:: ManagementCanister :: create ( & agent) ;
0 commit comments