-
Notifications
You must be signed in to change notification settings - Fork 16
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
Update ocp-indent to ocamlformat and replace action with rule stanza #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version=0.17.0 |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
(lang dune 1.0) | ||
(lang dune 2.8) | ||
(name proj) ; optional | ||
(version 0.0.0) ; optional |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ run-test: ["dune" "runtest" "-p" name] | |
|
||
depends: [ | ||
"dune" | ||
"ocamlformat" { >= "0.17.0" } | ||
"alcotest" {with-test} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
let now () = | ||
Unix.gettimeofday () | ||
let now () = Unix.gettimeofday () |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
(library | ||
(name test_sub1) | ||
(libraries | ||
alcotest | ||
proj.sub1 | ||
) | ||
(libraries alcotest proj.sub1) | ||
(synopsis "Tests for sub1")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
;; | ||
print_endline "Hello! The version is %%VERSION%%" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
; names = name of the files to compile into executables | ||
; public_names = name of the executables | ||
|
||
(executables | ||
(names foo_main bar_main) | ||
(public_names sub2-foo sub2-bar) | ||
(libraries | ||
proj.sub1 | ||
proj.sub2 | ||
) | ||
(libraries proj.sub1 proj.sub2) | ||
(package proj)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,42 +11,32 @@ open Printf | |
You may want to use Arg.parse_argv to read the remaining | ||
command-line arguments. | ||
*) | ||
let run _argv_offset = | ||
Proj_sub2.A.do_something () | ||
let run _argv_offset = Proj_sub2.A.do_something () | ||
|
||
let walk _argv_offset = | ||
print_endline "Nice." | ||
let walk _argv_offset = print_endline "Nice." | ||
|
||
(* Add your own subcommands as needed. *) | ||
let subcommands = [ | ||
"run", run; | ||
"walk", walk; | ||
] | ||
let subcommands = [ ("run", run); ("walk", walk) ] | ||
|
||
let help () = | ||
let subcommand_names = | ||
String.concat "\n" (List.map (fun (name, _f) -> " " ^ name) subcommands) | ||
in | ||
let usage_msg = sprintf "\ | ||
Usage: %s SUBCOMMAND [ARGS] | ||
where SUBCOMMAND is one of: | ||
%s | ||
|
||
For help on a specific subcommand, try: | ||
%s SUBCOMMAND --help | ||
" | ||
Sys.argv.(0) subcommand_names Sys.argv.(0) | ||
let usage_msg = | ||
sprintf | ||
"Usage: %s SUBCOMMAND [ARGS]\n\ | ||
where SUBCOMMAND is one of:\n\ | ||
%s\n\n\ | ||
For help on a specific subcommand, try:\n\ | ||
\ %s SUBCOMMAND --help\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's happening here with the leading backslash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll let you take a look in case it's a bug with ocamlformat that needs reporting or something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You know what, nevermind. I'll just fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I didn't notice this 😅, Thanks for fixing this! |
||
Sys.argv.(0) subcommand_names Sys.argv.(0) | ||
in | ||
eprintf "%s%!" usage_msg | ||
|
||
let dispatch_subcommand () = | ||
assert (Array.length Sys.argv > 1); | ||
match Sys.argv.(1) with | ||
| "help" | ||
| "-h" | ||
| "-help" | ||
| "--help" -> | ||
help () | ||
| "help" | "-h" | "-help" | "--help" -> help () | ||
| subcmd -> | ||
let argv_offset = 1 in | ||
let action = | ||
|
@@ -62,10 +52,8 @@ let main () = | |
let len = Array.length Sys.argv in | ||
if len <= 1 then ( | ||
help (); | ||
exit 1 | ||
) | ||
else | ||
dispatch_subcommand () | ||
exit 1) | ||
else dispatch_subcommand () | ||
|
||
(* Run now. *) | ||
let () = main () |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
(library | ||
(name proj_sub2) | ||
(public_name proj.sub2) | ||
(libraries | ||
unix | ||
str | ||
proj.sub1 | ||
) | ||
(libraries unix str proj.sub1) | ||
(synopsis "This is a short description of the sub2 library.")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
Tests for Sub2.A | ||
*) | ||
|
||
let tests = [ | ||
] | ||
let tests = [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
(library | ||
(name test_sub2) | ||
(libraries | ||
alcotest | ||
proj.sub2 | ||
) | ||
(libraries alcotest proj.sub2) | ||
(synopsis "Tests for sub2")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
(executable | ||
(name run_tests) | ||
(libraries | ||
alcotest | ||
test_sub1 | ||
test_sub2 | ||
)) | ||
(libraries alcotest test_sub1 test_sub2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like to have one thing per line so that the diff make sense when we add/remove items later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was something that was auto-generated by ocamlformat and as we are going to use ocamlformat in the future I thought leaving the formatted code in would be better here |
||
|
||
(alias | ||
(name runtest) | ||
(rule | ||
(alias runtest) | ||
(deps run_tests.exe) | ||
(action (run %{deps} -q --color=always))) | ||
(action | ||
(run %{deps} -q --color=always))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of this formatting style for lists but I'll get used to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was autogenerated by ocamlformat :D