Added add_container to cli 10/29010/3
authorMateusz Malicki <m.malicki2@samsung.com>
Mon, 20 Oct 2014 08:14:42 +0000 (10:14 +0200)
committerMateusz Malicki <m.malicki2@samsung.com>
Mon, 27 Oct 2014 11:09:21 +0000 (12:09 +0100)
[Feature]      Ability to add container through cli
[Cause]        The need for the ability to add containers
[Solution]     Add add_container cli function
[Verification] Build, install, run add container

Change-Id: I020bddaa3707f0e84227a35a85d0905fbb81d6be

cli/command-line-interface.cpp
cli/command-line-interface.hpp
cli/main.cpp

index 02c867f..a7b7aed 100644 (file)
@@ -111,5 +111,16 @@ void set_active_container(int pos, int argc, const char** argv)
     one_shot(bind(sc_set_active_container, _1, argv[pos + 1]));
 }
 
+void add_container(int pos, int argc, const char** argv)
+{
+    using namespace std::placeholders;
+
+    if (argc <= pos + 1) {
+        throw runtime_error("Not enough parameters");
+    }
+
+    one_shot(bind(sc_add_container, _1, argv[pos + 1]));
+}
+
 } // namespace cli
 } // namespace security_containers
index c193068..d9fc39f 100644 (file)
@@ -103,6 +103,13 @@ private:
  */
 void set_active_container(int pos, int argc, const char** argv);
 
+/**
+ * Parses command line arguments and call sc_add_container
+ *
+ * @see sc_add_container
+ */
+void add_container(int pos, int argc, const char** argv);
+
 } // namespace cli
 } // namespace security_containers
 
index e74f620..d84d5ac 100644 (file)
@@ -38,6 +38,12 @@ std::map<std::string, CommandLineInterface> commands = {
         "set_active_container container_id",
         "Set active (foreground) container",
         {{"container_id", "id container name"}}}
+    },
+    {"add_container", {
+        add_container,
+        "add_container container_id",
+        "Create and add container",
+        {{"container_id", "id container name"}}}
     }
 };