Browse Source

Cleaner way to remove warnings 40

Leo 10 years ago
parent
commit
845de8880f
9 changed files with 11 additions and 23 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 0
      TODO.md
  3. 1 3
      src/add_command.ml
  4. 2 4
      src/default.ml
  5. 1 3
      src/exec_cmd.ml
  6. 1 3
      src/list_rc.ml
  7. 2 4
      src/remove_command.ml
  8. 1 3
      src/state.ml
  9. 1 3
      src/tmp_file.ml

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
  + Add new command line option:
  + Add new command line option:
    + “-c file” allow to read configuration from custom file.
    + “-c file” allow to read configuration from custom file.
  + Improve “-l”: now display a “\*” next to current state.
  + Improve “-l”: now display a “\*” next to current state.
+ + Code clean up (Types in records)
 
 
 ## v0.2.0
 ## v0.2.0
  + Add new command line option.
  + Add new command line option.

+ 1 - 0
TODO.md

@@ -34,3 +34,4 @@
 ## Long term
 ## Long term
  + Translate displayed messages.
  + Translate displayed messages.
  + Better command line interface by grouping commands.
  + Better command line interface by grouping commands.
+ + Use Batteries instead of Core to improve apps size?

+ 1 - 3
src/add_command.ml

@@ -56,12 +56,10 @@ let new_list current_list position new_items =
 (* Function which add the commands (one per line) ridden on stdin to the rc
 (* Function which add the commands (one per line) ridden on stdin to the rc
  * file, and then display th new configuration *)
  * file, and then display th new configuration *)
 let run ~(rc:File_com.t) position =
 let run ~(rc:File_com.t) position =
-    (* We will use type rc_file *)
-    let open Settings_t in
     (* Read command from stdin, as a list. fix_win_eol removes \r\n *)
     (* Read command from stdin, as a list. fix_win_eol removes \r\n *)
     let cmd_list = In_channel.input_lines ~fix_win_eol:true In_channel.stdin in
     let cmd_list = In_channel.input_lines ~fix_win_eol:true In_channel.stdin in
     (* Create an updated rc file *)
     (* Create an updated rc file *)
-    let updated_rc = { rc with progs = (new_list rc.progs position cmd_list)} in
+    let updated_rc = { rc with Settings_t.progs = (new_list rc.Settings_t.progs position cmd_list)} in
     File_com.write updated_rc;
     File_com.write updated_rc;
     (* Display the result *)
     (* Display the result *)
     let reread_rc = File_com.init_rc () in
     let reread_rc = File_com.init_rc () in

+ 2 - 4
src/default.ml

@@ -45,14 +45,12 @@ let run ~rc:rc_content cmd_number =
   match cmd_number with
   match cmd_number with
     | None -> begin
     | None -> begin
         (* Execute each item (one by one) in config file *)
         (* Execute each item (one by one) in config file *)
-        let open Settings_t in (* This prevent warning 40 for ~cmd_list:rc_content.progs *)
-          let cmd_to_exec = Exec_cmd.what_next ~cmd_list:rc_content.progs in
+          let cmd_to_exec = Exec_cmd.what_next ~cmd_list:rc_content.Settings_t.progs in
             (* TODO Use display option in rc file *)
             (* TODO Use display option in rc file *)
             Exec_cmd.execute cmd_to_exec;
             Exec_cmd.execute cmd_to_exec;
       end
       end
     | Some num -> begin
     | Some num -> begin
-        let open Settings_t in
-        let cmd_to_exec = Exec_cmd.num_cmd_to_cmd ~cmd_list:rc_content.progs num in
+        let cmd_to_exec = Exec_cmd.num_cmd_to_cmd ~cmd_list:rc_content.Settings_t.progs num in
           Exec_cmd.execute cmd_to_exec;
           Exec_cmd.execute cmd_to_exec;
       end
       end
 ;;
 ;;

+ 1 - 3
src/exec_cmd.ml

@@ -60,10 +60,8 @@ let num_cmd_to_cmd ~cmd_list number =
 (* Function to determinate what is the next command to
 (* Function to determinate what is the next command to
  * execute. It take the current number from tmp file. *)
  * execute. It take the current number from tmp file. *)
 let what_next ~cmd_list =
 let what_next ~cmd_list =
-  (* We will use type tmp_file *)
-  let open Tmp_biniou_t in
   let tmp_file = Tmp_file.init () in
   let tmp_file = Tmp_file.init () in
-  num_cmd_to_cmd ~cmd_list:cmd_list tmp_file.number
+  num_cmd_to_cmd ~cmd_list:cmd_list tmp_file.Tmp_biniou_t.number
 ;;
 ;;
 
 
 (* Display an error message if command can't run
 (* Display an error message if command can't run

+ 1 - 3
src/list_rc.ml

@@ -47,8 +47,6 @@ let disp_cmd_num current_number number command =
 
 
 (* Function which list *)
 (* Function which list *)
 let run ~(rc:File_com.t) =
 let run ~(rc:File_com.t) =
-    (* We will use type rc_file *)
-    let open Settings_t in
-    List.iteri rc.progs ~f:(fun i item ->
+    List.iteri rc.Settings_t.progs ~f:(fun i item ->
         disp_cmd_num (State.get_current ()) i item)
         disp_cmd_num (State.get_current ()) i item)
 ;;
 ;;

+ 2 - 4
src/remove_command.ml

@@ -41,10 +41,8 @@ open Core.Std;;
 (* Function which add the commands (one per line) ridden on stdin to the rc
 (* Function which add the commands (one per line) ridden on stdin to the rc
  * file, and then display th new configuration *)
  * file, and then display th new configuration *)
 let run ~(rc:File_com.t) n_to_remove =
 let run ~(rc:File_com.t) n_to_remove =
-    (* We will use type rc_file *)
-    let open Settings_t in
     (* Get actual list of commands *)
     (* Get actual list of commands *)
-    let actual_list = rc.progs in
+    let actual_list = rc.Settings_t.progs in
     (* Get nth *)
     (* Get nth *)
     let nth = Option.value n_to_remove
     let nth = Option.value n_to_remove
         ~default:((List.length actual_list) - 1) in
         ~default:((List.length actual_list) - 1) in
@@ -62,7 +60,7 @@ let run ~(rc:File_com.t) n_to_remove =
             end
             end
     ) in
     ) in
     (* Write new list to rc file *)
     (* Write new list to rc file *)
-    let updated_rc = { rc with progs = new_list } in
+    let updated_rc = { rc with Settings_t.progs = new_list } in
     File_com.write updated_rc;
     File_com.write updated_rc;
     (* Display the result *)
     (* Display the result *)
     let reread_rc = File_com.init_rc () in
     let reread_rc = File_com.init_rc () in

+ 1 - 3
src/state.ml

@@ -40,12 +40,10 @@ open Core.Std;;
 
 
 (* Return current number *)
 (* Return current number *)
 let get_current () =
 let get_current () =
-    (* We will use type tmp_file *)
-    let open Tmp_biniou_t in
     (* Read tmp file *)
     (* Read tmp file *)
     let tmp_file = Tmp_file.init () in
     let tmp_file = Tmp_file.init () in
     (* Return the number *)
     (* Return the number *)
-    tmp_file.number;
+    tmp_file.Tmp_biniou_t.number;
 ;;
 ;;
 
 
 (* Display current number *)
 (* Display current number *)

+ 1 - 3
src/tmp_file.ml

@@ -107,12 +107,10 @@ let rec is_prog_in_rc list_from_rc_file program =
 (* Log when a program has been launched in a file in /tmp
 (* Log when a program has been launched in a file in /tmp
    ~func is the function applied to the value *)
    ~func is the function applied to the value *)
 let log ?(func= (+) 1 ) () =
 let log ?(func= (+) 1 ) () =
-  (* We will use tmp_file type *)
-  let open Tmp_biniou_t in
   (* Make sure that file exists, otherwise strange things appears *)
   (* Make sure that file exists, otherwise strange things appears *)
   let file = init () in
   let file = init () in
   (* Write the file with the new value *)
   (* Write the file with the new value *)
-  write { file with number = (func file.number)}
+  write { file with Tmp_biniou_t.number = (func file.Tmp_biniou_t.number)}
 ;;
 ;;
 
 
 (* Reset command number in two ways :
 (* Reset command number in two ways :