diff options
author | Galen Guyer <galen@galenguyer.com> | 2021-04-24 16:30:35 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2021-04-24 16:30:35 -0400 |
commit | 207f1a6fda89afe107209b7d27337973cc8d537b (patch) | |
tree | 5b7348e90b8449ebe3ed8d19116a072f6335f492 /composer.c | |
parent | 713f0eb14cc74384753bcf86b9d63e66db20a54a (diff) |
Assemble args with base file
Diffstat (limited to 'composer.c')
-rw-r--r-- | composer.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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); } |