changeset 21:8a086917cf1a

WIP: built all commands string
author atton
date Wed, 25 Nov 2015 19:43:01 +0900
parents c908e2c7315d
children 2f199ccd8e2d
files ie-docker.c ie-docker.h
diffstat 2 files changed, 24 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ie-docker.c	Tue Nov 24 17:31:55 2015 +0900
+++ b/ie-docker.c	Wed Nov 25 19:43:01 2015 +0900
@@ -215,12 +215,13 @@
 usage()
 {
     printf("Usage: ie-docker\n");
-    printf("\trun:    run process\n");
-    printf("\tbuild:  build docker process from Dockerfile\n");
-    printf("\tattach: attach process\n");
-    printf("\tdettach: dettach process\n");
-    printf("\timages: list images\n");
-    printf("\tcommit: \n");
+    printf("  ps:        show running containers\n");
+    printf("  run:       create new container\n");
+    printf("  start:     start created container\n");
+    printf("  stop:      stop running container\n");
+    printf("  attach:    attach running container\n");
+    printf("  cp <file>: copy file into container (/tmp) \n");
+    printf("  rm:        delete container\n");
 }
 
 void
@@ -290,22 +291,27 @@
         print_pslist(pslist); // TODO check work correctly
     } else if (command_is_matched(argv[1], run_command)) {
         sprintf(execl_command, "%s %s %s --name %s %s %s",
-                base_exec_command, run_command, "-it -u 2015 ", name, "java-centos", "zsh");    //FIXME
-        printf(execl_command); // TODO
+                base_exec_command, run_command, run_options, name, base_image_name, run_shell);
     } else if (command_is_matched(argv[1], start_command)) {
-        printf("start"); // TODO
+        sprintf(execl_command, "%s %s %s", base_exec_command, start_command, name);
     } else if (command_is_matched(argv[1], stop_command)) {
-        printf("stop"); // TODO
+        sprintf(execl_command, "%s %s %s", base_exec_command, stop_command, name);
     } else if (command_is_matched(argv[1], attach_command)) {
-        printf("attach"); // TODO
+        sprintf(execl_command, "%s %s %s", base_exec_command, attach_command, name);
     } else if (command_is_matched(argv[1], rm_command)) {
-        printf("rm"); // TODO
+        sprintf(execl_command, "%s %s %s", base_exec_command, rm_command, name);
     } else if (command_is_matched(argv[1], cp_command)) {
-        printf("cp"); // TODO
+        if (argc<3) {
+            printf("cp command requires file path\n");
+            return 0;
+        }
+        sprintf(execl_command, "%s %s %s %s:%s", base_exec_command, cp_command, argv[2], name, cp_file_path);
     } else {
         usage();
         return 0;
     }
+    printf(execl_command);
+    printf("\n");
     free(execl_command);
     return 0;
 }
--- a/ie-docker.h	Tue Nov 24 17:31:55 2015 +0900
+++ b/ie-docker.h	Wed Nov 25 19:43:01 2015 +0900
@@ -20,6 +20,11 @@
 
 #define create_command ""
 
+#define run_options      "-it -u 2015 "
+#define base_image_name  "java-centos"
+#define run_shell        "zsh"
+#define cp_file_path     "/tmp"
+
 /* Define global variables */
 
 const char *guests[] = {"mata"};