Skip to content

Commit 91e9908

Browse files
committed
feat(flags): add Flags.ProcessBase short-flag-free subset of Flags.Process
Adds a new public 'Flags.ProcessBase' struct alongside the existing 'Flags.Process'. ProcessBase is a minimal subset that does NOT claim the common short flags (-e, -u, -w, -i, -t), so downstream tools that wrap 'container' can @OptionGroup ProcessBase without colliding on those names. Motivation ---------- Tools like 'compose run' and 'compose exec' need to expose their own '-e KEY=VALUE' / '-u USER' / '-w DIR' UX (the docker-compose convention) but currently can't @OptionGroup Flags.Process because swift-argument-parser hits a parse-time clash on the short flags. The compose tooling's workaround is to declare verbose '--run-env', '--run-user', '--run-workdir' aliases that nobody types willingly. Adding ProcessBase upstream lets those wrappers inherit the safe long-form options (--cwd, --env-file) while reclaiming the short flags for their own subcommand-specific UX. What this PR changes -------------------- - Sources/Services/ContainerAPIService/Client/Flags.swift: a new public struct 'Flags.ProcessBase' with two fields ('cwd: String?', 'envFile: [String]'), declared with the same long-form @option attributes as the matching fields on 'Flags.Process'. No short flags. Existing 'Flags.Process' is unchanged. Total: 1 file, +37/-0. Wire compatibility ------------------ Pure additive — 'Flags.Process' is unchanged. Existing callers see no diff; new callers can opt into ProcessBase explicitly. Verification ------------ Full 'swift build' clean on macOS 26 / Apple silicon (release config, all targets).
1 parent caff1e9 commit 91e9908

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Sources/Services/ContainerAPIService/Client/Flags.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,43 @@ public struct Flags {
3030
public var debug = false
3131
}
3232

33+
/// Minimal subset of process-related options that intentionally does NOT
34+
/// claim the common short flags (`-e`, `-u`, `-w`, `-i`, `-t`).
35+
///
36+
/// Downstream tools that wrap `container` (e.g. `compose run` /
37+
/// `compose exec`) collide with `Flags.Process` because that struct
38+
/// registers the short flags itself. Embedding ``ProcessBase`` instead
39+
/// of ``Process`` lets the wrapping tool reclaim those short names for
40+
/// its own subcommand-specific options while still inheriting the safe
41+
/// long-form options (`--cwd`, `--env-file`).
42+
///
43+
/// Long-form behavior is identical to the matching fields in
44+
/// ``Process`` so a caller can switch between them without touching the
45+
/// rest of its `@OptionGroup` wiring.
46+
public struct ProcessBase: ParsableArguments {
47+
public init() {}
48+
49+
public init(cwd: String?, envFile: [String]) {
50+
self.cwd = cwd
51+
self.envFile = envFile
52+
}
53+
54+
@Option(
55+
name: .long,
56+
help: .init(
57+
"Set the initial working directory inside the container",
58+
valueName: "dir"
59+
)
60+
)
61+
public var cwd: String?
62+
63+
@Option(
64+
name: .long,
65+
help: "Read in a file of environment variables (key=value format, ignores # comments and blank lines)"
66+
)
67+
public var envFile: [String] = []
68+
}
69+
3370
public struct Process: ParsableArguments {
3471
public init() {}
3572

0 commit comments

Comments
 (0)