Parcourir la source

Code clean-up: command_def.ml.ml and list_rc.ml

 + Deal with wrapped optional arguments using ?option_arg instead of
 ~option_arg.
Leo il y a 9 ans
Parent
commit
822d3f1511
2 fichiers modifiés avec 3 ajouts et 8 suppressions
  1. 2 5
      src/command_def.ml
  2. 1 3
      src/list_rc.ml

+ 2 - 5
src/command_def.ml

@@ -142,11 +142,8 @@ let list =
     ~aliases:[ "--length" ; "-length" ; "--elength" ; "-elength" ]
          ~doc:" Max length of displayed entries, 0 keeps as-is"
   )
-  (fun { rc } length () ->
-    (* XXX A match case to deal with optionnal argument is tricky *)
-    match length with
-    | None -> List_rc.run ~rc ()
-    | Some l -> List_rc.run ~rc ~elength:l ())
+  (fun { rc } elength () ->
+    List_rc.run ~rc ?elength ())
 ;;
 
 (* To clean-up rc file *)

+ 1 - 3
src/list_rc.ml

@@ -94,9 +94,7 @@ let run ?rc ?elength () =
 
            (* Limit length, to get better display with long command. A default
             * length is involved when no length is specified *)
-           elength
-           |> (function None -> truncate cmd
-                      | Some elength -> truncate ~elength cmd);
+           truncate ?elength cmd;
 
            (Int.to_string number)
          ])