New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Padding of -help output with Arg (patch included) #8496
Comments
Comment author: administrator On Fri, Jun 11, 2004 at 04:47:48PM +0200, Damien Doligez wrote:
I agree completely, your solution is greater than my suggestion. Thanks for the Kenn |
Comment author: administrator
You can do it by indenting your source code carefully: let argspec = [ Moreover, I don't like to do it automatically because this is what I -c Compile file to opcodes. So what I'm going to do is expand the first space of the help To get what you want, you will simply need to add a space at the -- Damien |
Comment author: administrator wish (more or less) granted DD 2004-06-11 |
Original bug ID: 2297
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Kenneth Knowles
Version: ocaml 3.07
OS: linux 2.6.3
Submission from: adsl-64-162-212-212.dsl.snfc21.pacbell.net (64.162.212.212)
I think, for aesthetic reasons, that it is nice to align the help strings when
-help is specified for Arg.parse. I realize this is nearly trivial, but here
I've got a patch that pads the -help output (I use my modified Arg for many
projects):
-c Compile file to opcodes.
-o Specify output file.
-stdout Dump output to STDOUT instead of creating filename
instead of
-c Compile file to opcodes.
-o Specify output file.
-stdout Dump output to STDOUT instead of creating filename
Here is the patch from diff -u (I hope it comes out cleanly through this web
interface):
kenn@tallman frontends $ diff -u ~/src/ocaml/cvs/ocaml/stdlib/arg.ml arg.ml
--- /home/kenn/src/ocaml/cvs/ocaml/stdlib/arg.ml 2004-02-29
23:10:01.926620136 -0800
+++ arg.ml 2004-02-29 23:00:07.336193020 -0800
@@ -63,20 +63,36 @@
| h::t -> (List.fold_left (fun x y -> x ^ sep ^ y) (prefix ^ h) t) ^ suffix
;;
-let print_spec buf (key, spec, doc) =
+let pad str len =
']
+
+let print_spec ?(pad_to = 0) buf (key, spec, doc) =
match spec with
l)
"{" "|" "}" l)
doc
;;
+let rec maxkeylen ?(max = 0) li =
let usage_b buf speclist errmsg =
bprintf buf "%s\n" errmsg;
try ignore (assoc3 "-help" speclist)
"-help" maxlen);
try ignore (assoc3 "--help" speclist)
"--help" maxlen);
;;
let usage speclist errmsg =
The text was updated successfully, but these errors were encountered: