Skip to content

Refactor compose file flag into shared OptionGroup for up, down, and build.#98

Merged
Mcrich23 merged 8 commits into
mainfrom
copilot/fix-compose-file-option
May 30, 2026
Merged

Refactor compose file flag into shared OptionGroup for up, down, and build.#98
Mcrich23 merged 8 commits into
mainfrom
copilot/fix-compose-file-option

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

The compose file flag handling was duplicated across the two compose commands that accept -f/--file. This change centralizes that option in a shared argument group and wires both commands to consume it consistently.

  • Shared CLI option model

    • Added ComposeFileOptions as a reusable ParsableArguments type for -f/--file.
    • Keeps compose-file option definition in one place for both commands.
  • Command integration

    • Updated ComposeUp to use @OptionGroup var composeFileOptions.
    • Updated ComposeDown to use @OptionGroup var composeFileOptions.
    • Switched internal compose-file resolution paths to read from the shared option group.
  • Parsing coverage

    • Added static parsing tests to assert ComposeUp and ComposeDown both accept -f my-compose.yaml through the shared group.
public struct ComposeFileOptions: ParsableArguments, Sendable {
    @Option(name: [.customShort("f"), .customLong("file")], help: "The path to your Docker Compose file")
    public var composeFilename: String?
}

@OptionGroup
var composeFileOptions: ComposeFileOptions

Copilot AI changed the title Move compose file option into shared OptionGroup Refactor compose file flag into shared OptionGroup for up and down May 30, 2026
Copilot AI requested a review from Mcrich23 May 30, 2026 17:55
@testable import ContainerComposeCore

@Suite("Compose command parsing")
struct ComposeCommandParsingTests {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are kinda useless. However, check if calling "-f", "up" on the main entry point command is valid.

}
print(
"Info: Service '\(serviceName)' is configured to connect to networks: \(serviceNetworks.joined(separator: ", ")) ascertained from networks attribute in \(composeFilename)."
"Info: Service '\(serviceName)' is configured to connect to networks: \(serviceNetworks.joined(separator: ", ")) ascertained from networks attribute in \(composePath)."
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check the change on this variable name

@Mcrich23
Copy link
Copy Markdown
Owner

This looks decent @copilot. Please look at the comments I left.

@Mcrich23 Mcrich23 changed the title Refactor compose file flag into shared OptionGroup for up and down Refactor compose file flag into shared OptionGroup for up, down, and build. May 30, 2026
@Mcrich23 Mcrich23 marked this pull request as ready for review May 30, 2026 19:25
@Mcrich23 Mcrich23 merged commit b95d677 into main May 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants