Set the default command to printing some help

This commit is contained in:
Jeremie Dimino 2017-02-24 15:47:09 +00:00
parent 437a4fa5d7
commit dd77e045e6
2 changed files with 10 additions and 5 deletions

View File

@ -64,7 +64,7 @@ you can do right now is write some jbuild files, and invoke jbuilder
at the root of your project as follows: at the root of your project as follows:
#+begin_src #+begin_src
$ jbuilder <package>.install $ jbuilder build <package>.install
#+end_src #+end_src
Building the =.install= file will build all the things that need to be Building the =.install= file will build all the things that need to be

View File

@ -187,7 +187,7 @@ let resolve_targets (setup : Main.setup) user_targets =
| File path -> path | File path -> path
| Alias (_, alias) -> Alias.file alias) | Alias (_, alias) -> Alias.file alias)
let build_targets ~name = let build_targets =
let doc = "build targets" in let doc = "build targets" in
let name_ = Arg.info [] ~docv:"TARGET" in let name_ = Arg.info [] ~docv:"TARGET" in
let go common targets = let go common targets =
@ -199,7 +199,7 @@ let build_targets ~name =
( Term.(const go ( Term.(const go
$ common $ common
$ Arg.(non_empty & pos_all string [] name_)) $ Arg.(non_empty & pos_all string [] name_))
, Term.info name ~doc ~man:help_secs) , Term.info "build" ~doc ~man:help_secs)
let runtest = let runtest =
let doc = "run tests" in let doc = "run tests" in
@ -287,16 +287,21 @@ let all =
[ internal [ internal
; build_package ; build_package
; external_lib_deps ; external_lib_deps
; build_targets ~name:"build" ; build_targets
; runtest ; runtest
; install ; install
; uninstall ; uninstall
] ]
let default =
let doc = "fast, portable and opinionated build system for OCaml" in
( Term.(ret @@ const @@ `Help (`Pager, None))
, Term.info "jbuilder" ~doc)
let () = let () =
Ansi_color.setup_err_formatter_colors (); Ansi_color.setup_err_formatter_colors ();
try try
match Term.eval_choice (build_targets ~name:"jbuilder") all ~catch:false with match Term.eval_choice default all ~catch:false with
| `Error _ -> exit 1 | `Error _ -> exit 1
| _ -> exit 0 | _ -> exit 0
with exn -> with exn ->