From 4ff392d7bbf026589c2332e59922ffe92944a54e Mon Sep 17 00:00:00 2001 From: piquel Date: Sun, 22 Nov 2026 00:06:47 +0100 Subject: [PATCH 1/2] fix(cli): reject Git build flags on a service added from an image `app service add ` accepted `--branch`, `--commit`, `--dockerfile`, `--context`, `--build-arg` and `--target` and dropped them: clap skips a `requires = "git"` once an argument conflicting with `--git`, the image, is present. The image now conflicts with the build settings too, so the combination is a usage error, and the settings move into the Git choice of `NewSource`, which is the only one that uses them. Fixes PQD-137 --- apps/piquelctl/src/editing/services.rs | 25 ++++++++------ apps/piquelctl/tests/cli/editing.rs | 47 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/apps/piquelctl/src/editing/services.rs b/apps/piquelctl/src/editing/services.rs index 24c124048..c74094bc6 100644 --- a/apps/piquelctl/src/editing/services.rs +++ b/apps/piquelctl/src/editing/services.rs @@ -154,35 +154,40 @@ pub(crate) struct AddServiceArgs { target: ServiceTarget, #[command(flatten)] source: NewSource, - // Boxed to keep the CLI command enum small. - #[command(flatten)] - build: Box, } -// Where a new service's image comes from: exactly one of an image or `--git`. +// Where a new service's image comes from: exactly one of an image or `--git`, +// with the build settings only alongside `--git`. #[derive(Debug, Args)] struct NewSourceFlags { /// Image to run, such as `nginx:stable`. It may reference variables. /// Omit it when you pass `--git`. - #[arg(required_unless_present = "git", conflicts_with = "git")] + // The image also conflicts with the build settings, the `GitBuildArgs` + // group: clap skips their `requires = "git"` once an argument conflicting + // with `--git` is present. + #[arg(required_unless_present = "git", conflicts_with_all = ["git", "GitBuildArgs"])] image: Option