Parcourir la source

Merge branch 'dev' of ../oclaunch-code/. into dev

Leo il y a 9 ans
Parent
commit
9af3944dc1
3 fichiers modifiés avec 27 ajouts et 15 suppressions
  1. 1 0
      CHANGELOG.md
  2. 7 4
      src/licencing.ml
  3. 19 11
      src/messages.ml

+ 1 - 0
CHANGELOG.md

@@ -55,6 +55,7 @@ This version introduce major changes in the tmp and rc file.
  + Add licence warning.
  + Add licence warning.
  + Remove core\_extended dependency, incorporating some code from the library
  + Remove core\_extended dependency, incorporating some code from the library
    directly in the program, and using Textutils and Re2 library instead.
    directly in the program, and using Textutils and Re2 library instead.
+ + Display debugging information before each message.
  + TODO XXX Add basic signal handling (`--signals`), to relaunch when doing
  + TODO XXX Add basic signal handling (`--signals`), to relaunch when doing
    ctrl-C. See issue #14 for known problems.
    ctrl-C. See issue #14 for known problems.
 
 

+ 7 - 4
src/licencing.ml

@@ -41,7 +41,8 @@ open Core.Std;;
 (* French version *)
 (* French version *)
 let fr_header =
 let fr_header =
   "\
   "\
-  Copyright © Joly Clément, 2014-2015 \
+
+  Copyright © Joly Clément, 2014-2016 \
 
 
  leowzukw@vmail.me \
  leowzukw@vmail.me \
 
 
@@ -80,7 +81,8 @@ let fr_header =
 (* English version *)
 (* English version *)
 let en_header =
 let en_header =
   "\
   "\
-  Copyright © Joly Clément, 2015 \
+
+  Copyright © Joly Clément, 2014-2016 \
 
 
  leowzukw@vmail.me \
  leowzukw@vmail.me \
 
 
@@ -1209,9 +1211,10 @@ let print ~cecill =
            Option.value ~default:"" str |> Messages.debug;
            Option.value ~default:"" str |> Messages.debug;
            str)
            str)
 
 
+      |> Option.map ~f:String.lowercase
       |> (function
       |> (function
-           | Some "en" | Some "En" | Some "EN" -> `En
-           | Some "fr" | Some "Fr" | Some "FR"-> `Fr
+           | Some "en" -> `En
+           | Some "fr" -> `Fr
            | None | Some _ -> Messages.warning "Please enter 'Fr' or 'En'"; def_lang ()
            | None | Some _ -> Messages.warning "Please enter 'Fr' or 'En'"; def_lang ()
          ))
          ))
   in
   in

+ 19 - 11
src/messages.ml

@@ -101,7 +101,13 @@ let print ~color ~style message =
 (* Behave in a conform way to verbosity
 (* Behave in a conform way to verbosity
  * The higher is the number, the more important the message is, the lower
  * The higher is the number, the more important the message is, the lower
  * verbosity value display it *)
  * verbosity value display it *)
-let check_verbosity ~f function_number =
+(* f: function to show the message
+ * debug: fonction to call before f, for instance a debugging function displaying
+ * date and time *)
+let check_verbosity ?debug ~f function_number =
+  (* Debugging function *)
+  debug |> (function None -> () | Some debug_fonction -> debug_fonction "");
+
   match function_number <= !Const.verbosity with
   match function_number <= !Const.verbosity with
     true -> (* Display the message *)
     true -> (* Display the message *)
     f ()
     f ()
@@ -118,14 +124,14 @@ let debug message =
 ;;
 ;;
 
 
 let info message =
 let info message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          let mess = message ^ "\n" in
          print ~color:White ~style:Bold mess
          print ~color:White ~style:Bold mess
        ) 3
        ) 3
 ;;
 ;;
 
 
 let warning message =
 let warning message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          let mess = message ^ "\n" in
          print ~color:Red ~style:Bold mess
          print ~color:Red ~style:Bold mess
        ) 1
        ) 1
@@ -160,24 +166,26 @@ let rec confirm info =
          (* XXX Be sure to show the message *)
          (* XXX Be sure to show the message *)
          Out_channel.(flush stdout);
          Out_channel.(flush stdout);
          let str_answer = In_channel.(input_line ~fix_win_eol:true stdin) in
          let str_answer = In_channel.(input_line ~fix_win_eol:true stdin) in
-         str_answer |> (function
-                | Some "Y" | Some "y" | Some "Yes" | Some "YES" | Some "yes" -> Yes
-                | Some "N" | Some "n" | Some "No" | Some "NO" | Some "no" -> No
-                | Some _ | None ->
-                  warning "Please enter 'yes' or 'no' or 'y' or 'n'.";
-                  confirm info)
+         str_answer |> Option.map ~f:String.lowercase
+         |> (function
+              | Some "y" | Some "ye" | Some "yes" -> Yes
+              | Some "n" | Some "no" -> No
+              | Some _ | None ->
+                warning "Please enter 'yes' or 'no', or 'y' or 'n' (case \
+                doesn't matter).";
+                confirm info)
        )
        )
 ;;
 ;;
 
 
 let ok message =
 let ok message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          let mess = message ^ "\n" in
          print ~color:Green ~style:Bold mess
          print ~color:Green ~style:Bold mess
        ) 2
        ) 2
 ;;
 ;;
 
 
 let tips message =
 let tips message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          let mess = message ^ "\n" in
          print ~color:Yellow ~style:Normal mess
          print ~color:Yellow ~style:Normal mess
        ) 4
        ) 4