Parcourir la source

Execute each item of the configuration file

Leo il y a 10 ans
Parent
commit
b68418721b
3 fichiers modifiés avec 18 ajouts et 10 suppressions
  1. 2 2
      Makefile
  2. 11 4
      oclaunch.ml
  3. 5 4
      test.json

+ 2 - 2
Makefile

@@ -7,5 +7,5 @@ atdgen:
 mli:
 mli:
 	corebuild -pkg yojson,atdgen file_com.inferred.mli
 	corebuild -pkg yojson,atdgen file_com.inferred.mli
 
 
-code: mli
-	corebuild -pkg yojson,atdgen oclaunch.byte
+code:
+	corebuild -pkg core_extended,yojson,atdgen oclaunch.byte

+ 11 - 4
oclaunch.ml

@@ -43,7 +43,14 @@ let rc_file = "test.json" (* TODO Dev value, change this *)
 let rc_content = File_com.init ~rc:rc_file;;
 let rc_content = File_com.init ~rc:rc_file;;
 
 
 (* Execute some command and log it *)
 (* Execute some command and log it *)
-let execute cmd =
-	Core_extended.Shell.run_full cmd
-	|> print_endline
-;;
+let execute ?(display=false) cmd =
+	if display then
+		print_endline cmd;
+	(* Core_extended.Shell.sh ~echo:display cmd (* Echo value allow to print the command *) *)
+	Sys.command cmd (* TODO Use Core lib instead of Pervasive *)
+	|> print_int;
+	cmd
+;;
+
+(* Execute each item in config file *)
+List.map ~f:execute rc_content.progs;;

+ 5 - 4
test.json

@@ -1,9 +1,10 @@
 {
 {
     "progs" : [
     "progs" : [
-        "First one",
-        "Second one",
-        "And so on"
-    ]
+        "echo test",
+        "task",
+        "task +rdv",
+        "vim"
+    ],
 
 
     "settings" : [
     "settings" : [
         "Todo"
         "Todo"