Skip to content

Commit b2847a4

Browse files
committed
Add --services parameters to docker command
1 parent 99a17bf commit b2847a4

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ The following options are global and precede the actual command on the command l
240240
cargo xtask -e production build
241241
```
242242

243-
Its mainf role is to inform your custom commands or dispatch functions about the targeted environment which can be:
243+
Its main role is to inform your custom commands or dispatch functions about the targeted environment which can be:
244244
- `dev` (default) for development,
245245
- `test` for test,
246246
- `stag` for staging,
@@ -864,7 +864,7 @@ configuration mechanism of `tracel-xtask`.
864864
The name of the compose file must follow the template `docker-compose.{env}.yml` with `env` being the shorthand environment name.
865865
For instance for the development environment the file is named `docker-compose.dev.yml`.
866866

867-
The command also requires a mandatory project name for the stack in order to have idempotent `up` command.
867+
The command also requires a mandatory project name for the stack in order to have idempotent `up` commands.
868868

869869
### Dependencies
870870

crates/tracel-xtask-macros/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ fn get_additional_cmd_args_map() -> HashMap<&'static str, proc_macro2::TokenStre
263263
#[doc = r"Project name."]
264264
#[arg(short, long, required = true)]
265265
pub project: String,
266+
#[doc = r"Space separated list of service subset to start. If empty then launch all the services in the stack."]
267+
#[arg(short, long, num_args(1..), required = false)]
268+
pub services: Vec<String>,
266269
},
267270
),
268271
(

crates/tracel-xtask/src/commands/docker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct DockerCmdArgs {}
77

88
pub fn handle_command(args: DockerCmdArgs, env: Environment, _ctx: Context) -> anyhow::Result<()> {
99
match args.get_command() {
10-
DockerSubCommand::Up => up_docker_compose(&env, &args.project, args.build, vec![]),
10+
DockerSubCommand::Up => up_docker_compose(&env, &args.project, args.build, args.services),
1111
DockerSubCommand::Down => down_docker_compose(&env, &args.project),
1212
}
1313
}
@@ -20,7 +20,7 @@ pub fn up_docker_compose(
2020
env: &Environment,
2121
project: &str,
2222
build: bool,
23-
services: Vec<&str>,
23+
services: Vec<String>,
2424
) -> anyhow::Result<()> {
2525
let env_name = env.to_string();
2626
let dotenv_filepath = env.get_dotenv_filename();
@@ -40,7 +40,7 @@ pub fn up_docker_compose(
4040
if build {
4141
args.extend(vec!["--build"]);
4242
}
43-
args.extend(services);
43+
args.extend(services.iter().map(String::as_str));
4444
let result = run_process(
4545
"docker",
4646
&args,

crates/tracel-xtask/src/environment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ pub enum Environment {
2525
}
2626

2727
impl Environment {
28-
pub(crate) fn get_dotenv_filename(&self) -> String {
28+
pub fn get_dotenv_filename(&self) -> String {
2929
format!(".env.{}", self)
3030
}
3131

32-
pub(crate) fn get_dotenv_secrets_filename(&self) -> String {
32+
pub fn get_dotenv_secrets_filename(&self) -> String {
3333
format!("{}.secrets", self.get_dotenv_filename())
3434
}
3535

0 commit comments

Comments
 (0)