From 207f1a6fda89afe107209b7d27337973cc8d537b Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Sat, 24 Apr 2021 16:30:35 -0400 Subject: Assemble args with base file --- composer.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'composer.c') diff --git a/composer.c b/composer.c index 0e68400..97c5a41 100644 --- a/composer.c +++ b/composer.c @@ -1,9 +1,27 @@ #include +#include #include #define COMMAND "echo" int main(int argc, char** argv) { - int result = execvp(COMMAND, argv); + // TODO: Support docker-compose.yaml too + if (access("docker-compose.yaml", R_OK) < 0) { + fprintf(stderr, "No 'docker-compose.yaml' file found\n"); + exit(1); + } + char* args[argc+2]; + args[0] = COMMAND; + args[1] = "-f"; + args[2] = "docker-compose.yaml"; + for (int i = 2; i < argc; i++) { + args[i] = argv[i-1]; + } + args[argc+2] = NULL; + for(int i = 0; i < argc+2; i++) { + printf("%s ", args[i]); + } + puts(""); + int result = execvp(COMMAND, args); if (result < 0) { perror(COMMAND); } -- cgit v1.2.3