Add -u/--up and -d/--down, wired to compose-parser stub commands

Both take a required OCI images directory plus an optional compose file
name (defaulting to "compose.yaml", resolved relative to the cwd) via the
same manual two-token consumption -v/--volume already uses, just with the
second token optional. The stub commands aren't no-ops: they resolve the
images directory, load and validate the compose file through the existing
load_compose_file()/validate_compose_external_state(), and print a summary
-- confirming the CLI wiring and parser work end to end -- before logging
that actual orchestration isn't implemented yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
2026-09-07 10:45:48 +00:00
parent a626ff2cdd
commit f354463b40
4 changed files with 159 additions and 3 deletions
+45
View File
@@ -249,3 +249,48 @@ TEST_CASE("parse_args: --log-level sets log_level_flag_given", "[unit]") {
REQUIRE_FALSE(with_level.exit_code.has_value());
CHECK(with_level.args.log_level_flag_given);
}
TEST_CASE("parse_args: -u/--up defaults compose_file_name to compose.yaml when omitted", "[unit]") {
auto result = run_parse({"-u", "/var/lib/images"});
REQUIRE_FALSE(result.exit_code.has_value());
CHECK(result.args.mode == Mode::compose_up);
REQUIRE(result.args.compose_images_directory.has_value());
CHECK(*result.args.compose_images_directory == "/var/lib/images");
CHECK(result.args.compose_file_name == "compose.yaml");
}
TEST_CASE("parse_args: -u accepts an explicit second token as compose_file_name", "[unit]") {
auto result = run_parse({"-u", "/var/lib/images", "my-stack.yaml"});
REQUIRE_FALSE(result.exit_code.has_value());
CHECK(result.args.mode == Mode::compose_up);
CHECK(*result.args.compose_images_directory == "/var/lib/images");
CHECK(result.args.compose_file_name == "my-stack.yaml");
}
TEST_CASE("parse_args: -u doesn't swallow a following flag as compose_file_name", "[unit]") {
auto result = run_parse({"-u", "/var/lib/images", "--log-level", "debug"});
REQUIRE_FALSE(result.exit_code.has_value());
CHECK(result.args.mode == Mode::compose_up);
CHECK(*result.args.compose_images_directory == "/var/lib/images");
// The default, since "--log-level" looks like a flag, not a filename.
CHECK(result.args.compose_file_name == "compose.yaml");
CHECK(result.args.log_level_flag_given);
}
TEST_CASE("parse_args: -d/--down works the same way as -u/--up", "[unit]") {
auto default_name = run_parse({"--down", "/var/lib/images"});
REQUIRE_FALSE(default_name.exit_code.has_value());
CHECK(default_name.args.mode == Mode::compose_down);
CHECK(default_name.args.compose_file_name == "compose.yaml");
auto explicit_name = run_parse({"-d", "/var/lib/images", "my-stack.yaml"});
REQUIRE_FALSE(explicit_name.exit_code.has_value());
CHECK(explicit_name.args.mode == Mode::compose_down);
CHECK(explicit_name.args.compose_file_name == "my-stack.yaml");
}
TEST_CASE("parse_args: -u and -d together on the same command line is a parse error", "[unit]") {
auto result = run_parse({"-u", "/var/lib/images", "-d", "/var/lib/images"});
REQUIRE(result.exit_code.has_value());
CHECK(*result.exit_code == 1);
}