diff options
author | Galen Guyer <galen@galenguyer.com> | 2021-04-24 16:31:37 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2021-04-24 16:31:37 -0400 |
commit | 4d1c2ea834cac7024d9f51e707b911601f8c5ea8 (patch) | |
tree | be358cf771a0ed7683c61bb90a8c4fde1b2f8aa8 /composer.c | |
parent | 207f1a6fda89afe107209b7d27337973cc8d537b (diff) |
Put together all compose files and args
Diffstat (limited to 'composer.c')
-rw-r--r-- | composer.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -1,7 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#define COMMAND "echo" +#include <glob.h> + +#define COMMAND "docker-compose" int main(int argc, char** argv) { // TODO: Support docker-compose.yaml too @@ -9,18 +11,23 @@ int main(int argc, char** argv) { fprintf(stderr, "No 'docker-compose.yaml' file found\n"); exit(1); } - char* args[argc+2]; + + glob_t glob_buf; + glob("docker-compose.*.yaml", 0, NULL, &glob_buf); + + char* args[argc+2+(2*glob_buf.gl_pathc)]; args[0] = COMMAND; args[1] = "-f"; args[2] = "docker-compose.yaml"; - for (int i = 2; i < argc; i++) { - args[i] = argv[i-1]; + for(size_t i = 0; i < glob_buf.gl_pathc; i++) { + args[(2*i)+3] = "-f"; + args[(2*i)+4] = glob_buf.gl_pathv[i]; } - args[argc+2] = NULL; - for(int i = 0; i < argc+2; i++) { - printf("%s ", args[i]); + for (int i = 1; i < argc; i++) { + args[2+(2*glob_buf.gl_pathc)+i] = argv[i]; } - puts(""); + args[argc+2+(2*glob_buf.gl_pathc)] = NULL; + int result = execvp(COMMAND, args); if (result < 0) { perror(COMMAND); |