@@ -25,17 +25,22 @@ pub struct SetupArgs {
2525 pub bootstrap : bool ,
2626
2727 /// Run setup for a remote host instead of local Docker
28- #[ arg( long) ]
29- pub host : Option < String > ,
28+ #[ arg( long, conflicts_with = "local" ) ]
29+ pub remote_host : Option < String > ,
30+
31+ /// Force local Docker (ignores default_host)
32+ #[ arg( long, conflicts_with = "remote_host" ) ]
33+ pub local : bool ,
3034}
3135
3236/// Run the setup command
3337pub async fn cmd_setup ( args : & SetupArgs , quiet : bool ) -> Result < ( ) > {
3438 // Load existing config (or create default)
3539 let existing_config = load_config_or_default ( ) . ok ( ) ;
40+ let target_host = crate :: resolve_target_host ( args. remote_host . as_deref ( ) , args. local ) ;
3641
3742 if args. bootstrap {
38- return run_bootstrap_setup ( existing_config, args . host . as_deref ( ) , quiet) . await ;
43+ return run_bootstrap_setup ( existing_config, target_host . as_deref ( ) , quiet) . await ;
3944 }
4045
4146 // Handle --yes flag for non-interactive mode
@@ -75,7 +80,7 @@ pub async fn cmd_setup(args: &SetupArgs, quiet: bool) -> Result<()> {
7580 println ! ( ) ;
7681
7782 // Check if container is already running
78- let ( client, host_name) = crate :: resolve_docker_client ( args . host . as_deref ( ) ) . await ?;
83+ let ( client, host_name) = crate :: resolve_docker_client ( target_host . as_deref ( ) ) . await ?;
7984 let is_running = container_is_running ( & client, CONTAINER_NAME )
8085 . await
8186 . unwrap_or ( false ) ;
@@ -117,7 +122,7 @@ pub async fn cmd_setup(args: &SetupArgs, quiet: bool) -> Result<()> {
117122 timeout : 60 ,
118123 remove : false ,
119124 } ;
120- cmd_stop ( & stop_args, args . host . as_deref ( ) , quiet) . await ?;
125+ cmd_stop ( & stop_args, target_host . as_deref ( ) , quiet) . await ?;
121126 println ! ( ) ;
122127 }
123128
@@ -126,14 +131,14 @@ pub async fn cmd_setup(args: &SetupArgs, quiet: bool) -> Result<()> {
126131 port : Some ( new_config. opencode_web_port ) ,
127132 ..Default :: default ( )
128133 } ;
129- cmd_start ( & start_args, args . host . as_deref ( ) , quiet, 0 ) . await ?;
134+ cmd_start ( & start_args, target_host . as_deref ( ) , quiet, 0 ) . await ?;
130135
131136 Ok ( ( ) )
132137}
133138
134139async fn run_bootstrap_setup (
135140 existing_config : Option < Config > ,
136- host : Option < & str > ,
141+ target_host : Option < & str > ,
137142 quiet : bool ,
138143) -> Result < ( ) > {
139144 let new_config = build_bootstrap_config ( existing_config. clone ( ) ) ;
@@ -143,7 +148,7 @@ async fn run_bootstrap_setup(
143148 return start_or_restart_after_setup (
144149 existing_config. as_ref ( ) ,
145150 & new_config,
146- host ,
151+ target_host ,
147152 quiet,
148153 true ,
149154 )
@@ -161,7 +166,14 @@ async fn run_bootstrap_setup(
161166 ) ;
162167 println ! ( ) ;
163168
164- start_or_restart_after_setup ( existing_config. as_ref ( ) , & new_config, host, quiet, true ) . await
169+ start_or_restart_after_setup (
170+ existing_config. as_ref ( ) ,
171+ & new_config,
172+ target_host,
173+ quiet,
174+ true ,
175+ )
176+ . await
165177}
166178
167179fn build_bootstrap_config ( existing_config : Option < Config > ) -> Config {
@@ -176,11 +188,11 @@ fn build_bootstrap_config(existing_config: Option<Config>) -> Config {
176188async fn start_or_restart_after_setup (
177189 existing_config : Option < & Config > ,
178190 new_config : & Config ,
179- host : Option < & str > ,
191+ target_host : Option < & str > ,
180192 quiet : bool ,
181193 non_interactive : bool ,
182194) -> Result < ( ) > {
183- let ( client, host_name) = crate :: resolve_docker_client ( host ) . await ?;
195+ let ( client, host_name) = crate :: resolve_docker_client ( target_host ) . await ?;
184196 let is_running = container_is_running ( & client, CONTAINER_NAME )
185197 . await
186198 . unwrap_or ( false ) ;
@@ -199,14 +211,14 @@ async fn start_or_restart_after_setup(
199211 timeout : 60 ,
200212 remove : false ,
201213 } ;
202- cmd_stop ( & stop_args, host , quiet || non_interactive) . await ?;
214+ cmd_stop ( & stop_args, target_host , quiet || non_interactive) . await ?;
203215 }
204216
205217 let start_args = crate :: commands:: StartArgs {
206218 port : Some ( new_config. opencode_web_port ) ,
207219 ..Default :: default ( )
208220 } ;
209- cmd_start ( & start_args, host , quiet || non_interactive, 0 ) . await ?;
221+ cmd_start ( & start_args, target_host , quiet || non_interactive, 0 ) . await ?;
210222 Ok ( ( ) )
211223}
212224
0 commit comments