aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalen Guyer <galen@galenguyer.com>2021-04-24 16:30:35 -0400
committerGalen Guyer <galen@galenguyer.com>2021-04-24 16:30:35 -0400
commit207f1a6fda89afe107209b7d27337973cc8d537b (patch)
tree5b7348e90b8449ebe3ed8d19116a072f6335f492
parent713f0eb14cc74384753bcf86b9d63e66db20a54a (diff)
Assemble args with base file
-rw-r--r--composer.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/composer.c b/composer.c
index 0e68400..97c5a41 100644
--- a/composer.c
+++ b/composer.c
@@ -1,9 +1,27 @@
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#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);
}