Skip to content

Commit

Permalink
Make redtt run again (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia authored Mar 25, 2022
1 parent 49783bd commit ae76658
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OPAM=opam
EXEC=${OPAM} config exec
EXEC=${OPAM} exec
DUNE=${EXEC} dune --

.PHONY: all build clean doc help library install reinstall top
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(lang dune 2.1.1)
(lang dune 2.1)
(using menhir 2.0) ; required for dune to pass --infer to menhir
2 changes: 1 addition & 1 deletion library/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OPAM=opam
EXEC=${OPAM} config exec
EXEC=${OPAM} exec
DUNE=${EXEC} dune --

RED_FILES=$(wildcard ./**/*.red)
Expand Down
37 changes: 14 additions & 23 deletions src/bin/main.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open Cmdliner
open RedTT

type command = unit Term.t * Term.info
type command = unit Cmd.t

let opt_margin =
let doc = "Set pretty-printing margin to $(docv) characters." in
Expand Down Expand Up @@ -31,34 +31,28 @@ let opts_config =
let make file_name line_width debug_mode shell_mode recheck =
Frontend.{file_name; line_width; debug_mode; shell_mode; recheck}
in
pure make $ opt_file_name $ opt_margin $ opt_debug $ opt_shell $ opt_recheck
const make $ opt_file_name $ opt_margin $ opt_debug $ opt_shell $ opt_recheck

let cmd_default =
Term.
( ret @@ pure @@ `Help ( `Pager, None )
, info "redtt" ~version:"0.1.0"
)
let term_default =
Term.(ret @@ const @@ `Help ( `Pager, None ))

let info_default =
Cmd.(info "redtt" ~version:"0.1.0")

let cmd_help =
let doc = "show help" in
Term.
( ret @@ pure @@ `Help ( `Pager, None )
, info "help" ~doc
)
Cmd.(v @@ info "help" ~doc)
Term.(ret @@ const @@ `Help ( `Pager, None ))

let cmd_load_file =
let doc = "load file" in
Term.
( pure Frontend.load_file $ opts_config
, info "load-file" ~doc
)
Cmd.(v @@ info "load-file" ~doc)
Term.(const Frontend.load_file $ opts_config)

let cmd_from_stdin =
let doc = "read from stdin" in
Term.
( pure Frontend.load_from_stdin $ opts_config
, info "from-stdin" ~doc
)
Cmd.(v @@ info "from-stdin" ~doc)
Term.(const Frontend.load_from_stdin $ opts_config)


let cmds : command list = [
Expand All @@ -68,10 +62,7 @@ let cmds : command list = [
]

let main () =
match Term.eval_choice cmd_default cmds with
| `Error _e -> exit 1
| `Ok expr -> expr
| _ -> exit 0
Stdlib.exit @@ Cmd.eval @@ Cmd.group ~default:term_default info_default cmds

let () =
if not !Sys.interactive then
Expand Down

0 comments on commit ae76658

Please sign in to comment.