Parcourir la source

Add licencing functionality

 - Add text for the licence and headers
 - Display header on first use (in the right language)
 - Some problem: sometimes the messages was not displayed, solved by flushing
   stdout
Leo il y a 9 ans
Parent
commit
4e2819302a
3 fichiers modifiés avec 1257 ajouts et 1 suppressions
  1. 17 1
      src/command_def.ml
  2. 4 0
      src/file_com.ml
  3. 1236 0
      src/licencing.ml

+ 17 - 1
src/command_def.ml

@@ -172,6 +172,22 @@ let edit =
       Edit_command.run ~rc default_n)
 ;;
 
+(* To display informations about the licence *)
+let licence =
+  basic
+    ~summary:"Display the licence of the program"
+    Spec.(
+      empty
+       +> shared_params
+       +> flag "-header" no_arg
+        ~doc:" Display the text of the licence"
+    )
+    (fun _ header () ->
+      let cecill = not(header) in (* When cecill is false, it displays the header *)
+      Licencing.print ~cecill
+    )
+;;
+
 (* Run th enth command, default use *)
 let default =
   basic
@@ -192,7 +208,7 @@ let run ~version ~build_info () =
       http://cecill.info/licences/Licence_CeCILL_V2.1-en.html (http://huit.re/TmdOFmQT) for details."
       ~readme:(fun () -> "See http://oclaunch.tuxfamily.org for help.")
       [ ( "reset-tmp", reset) ; ("list", list) ; ("add", add) ; ("delete",
-      delete) ; ("state", state) ; ("edit", edit) ; ("run", default) ]
+      delete) ; ("state", state) ; ("edit", edit) ; ("licence", licence) ; ("run", default) ]
     |> run ~version ~build_info
     with
     | () -> `Exit 0

+ 4 - 0
src/file_com.ml

@@ -62,6 +62,10 @@ let create_rc_file ~name =
   (* Notify that we initialise config file *)
   sprintf "Initializing empty configuration file in %s\n" name |> Messages.warning;
   Messages.tips "Feedback is welcomed at leowzukw@vmail.me\n";
+
+  (* Display licence information *)
+  Licencing.print ~cecill:false;
+
   let compact_rc_file = Settings_j.string_of_rc_file (rc_template () ()) in
   let readable_rc_file = Yojson.Basic.prettify compact_rc_file in (* Create human readable string for rc file *)
   let out_file = Out_channel.create name in

Fichier diff supprimé car celui-ci est trop grand
+ 1236 - 0
src/licencing.ml