Skip to content

Commit

Permalink
Fix all the dune-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
smondet committed Feb 18, 2020
1 parent 3ad733e commit cfa3e7a
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 151 deletions.
4 changes: 2 additions & 2 deletions src/examples/downloader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ let downloader () =
let to_loop name_variable t_list =
loop_while
(string_matches_any name_variable#get
(List.map t_list (fun t -> sprintf "\\.%s$" t.extension)))
(List.map t_list ~f:(fun t -> sprintf "\\.%s$" t.extension)))
~body:(to_switch name_variable t_list)

let all =
Expand Down Expand Up @@ -138,7 +138,7 @@ let downloader () =
"Download archives and decrypt/unarchive them.\n\
./downloader -u URL [-c] [-f <file>] [-t <tmpdir>]"
in
Command_line.parse cli_spec (fun ~anon url all_in_tmp filename_ov tmp_dir ->
Command_line.parse cli_spec (fun ~anon:_ url all_in_tmp filename_ov tmp_dir ->
let current_name = tmp_file ~tmp_dir "current-name" in
let set_output_of_download () =
if_seq
Expand Down
4 changes: 2 additions & 2 deletions src/examples/multigit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Pretty cool, right:
[ if_seq version
~t:[out (sprintf "%s: %s" name version_string) []]
~e:
[ setenv (str "PAGER") (str "cat")
[ setenv ~var:(str "PAGER") (str "cat")
; Elist.iter anon ~f:(fun p -> do_section (p ()))
; if_seq no_config ~t:[]
~e:
Expand Down Expand Up @@ -593,7 +593,7 @@ module Meta_repository = struct
in
loop []

let readme_md ~path ~output =
let readme_md ~path:_ ~output =
let o = open_out output in
let open Format in
let fmt = formatter_of_out_channel o in
Expand Down
69 changes: 29 additions & 40 deletions src/examples/service_composer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ module Version = struct
; tm_mday
; tm_mon
; tm_year
; tm_wday
; tm_yday
; tm_isdst } ->
; _ } ->
sprintf "%4d%02d%02d.%02d%02d%02d" (1900 + tm_year) (1 + tm_mon)
tm_mday tm_hour tm_min tm_sec)

Expand Down Expand Up @@ -296,7 +294,7 @@ module Manual = struct

let () =
add
@@ from (fun ~root env ->
@@ from (fun ~root _ ->
ksprintf title "%s: Compose Processes With Screen" (pre_title root)
)
@ from (fun ~root env ->
Expand Down Expand Up @@ -329,7 +327,7 @@ module Manual = struct
root env.Environment.default_configuration_path )
@ extended
( section "Installation"
@ from (fun ~root env ->
@ from (fun ~root _ ->
ksprintf par
"Simply copy `%s*` to somewhere in your `$PATH`, the scripts \
depend on a reasonably valid version of `/bin/sh` and GNU \
Expand All @@ -339,7 +337,7 @@ module Manual = struct
"If you are using the code-generator, you can just point \
the `--output-path` option at the right directory." ) )
@ section "Usage"
@ from (fun ~root env ->
@ from (fun ~root _ ->
let intro fmt =
ksprintf
(ksprintf par
Expand All @@ -358,7 +356,7 @@ module Manual = struct
`%s <command> --help`."
root root )
@ section "Screen Session Isolation"
@ from (fun ~root env ->
@ from (fun ~root _ ->
ksprintf par
"`%s` isolates Screen sessions by using their session name." root
@ ksprintf par
Expand All @@ -379,7 +377,7 @@ module Manual = struct
root )
@ extended
( section "Docker Image For the Generator"
@ from (fun ~root env ->
@ from (fun ~root:_ _ ->
let image = "smondet/genspio-doc-dockerfiles:apps406" in
ksprintf par
"If you have [`opam`](https://opam.ocaml.org), setting up the \
Expand Down Expand Up @@ -578,7 +576,7 @@ module Manual_script = struct
& flag ["--no-pager"] ~doc:"Do not use a pager."
& describe_option_and_usage ()
in
parse opts (fun ~anon extended no_pager describe ->
parse opts (fun ~anon:_ extended no_pager describe ->
deal_with_describe describe
[Manual.output ~root ~env extended ||> pager ~disable:no_pager ()]
) )
Expand All @@ -591,7 +589,7 @@ module Version_script = struct
let description = "Show the version information."
end)

let make ~env () =
let make ~env:_ () =
Script.make [name] ~description (fun ~root ->
let open Gedsl in
let open Command_line in
Expand All @@ -600,7 +598,7 @@ module Version_script = struct
flag ["--extended"; "-X"] ~doc:"Provide extra information"
& describe_option_and_usage ()
in
parse opts (fun ~anon extended describe ->
parse opts (fun ~anon:_ extended describe ->
deal_with_describe describe
[ if_seq extended
~t:
Expand All @@ -617,7 +615,7 @@ module Init_script = struct
end)

let make ~env () =
Script.make ["configuration"; name] ~description (fun ~root ->
Script.make ["configuration"; name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
Expand All @@ -631,7 +629,7 @@ module Init_script = struct
~default:(Environment.make_default_screen_name env)
& describe_option_and_usage ()
in
parse opts (fun ~anon screen_name describe ->
parse opts (fun ~anon:_ screen_name describe ->
deal_with_describe describe
[Environment.init ~screen_name env; say "Done." []] ) )
end
Expand All @@ -644,7 +642,7 @@ module Add_job_script = struct
end)

let make ~env () =
Script.make ["configuration"; name] ~description (fun ~root ->
Script.make ["configuration"; name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let default_none = str "--none--" in
Expand All @@ -660,7 +658,7 @@ module Add_job_script = struct
like `top`)"
& describe_option_and_usage ()
in
parse opts (fun ~anon name shell_command interpreter no_log describe ->
parse opts (fun ~anon:_ name shell_command interpreter no_log describe ->
let jpath = Job.job_path env name in
deal_with_describe describe
[ if_then
Expand Down Expand Up @@ -689,13 +687,10 @@ module Remove_job_script = struct
end)

let make ~env () =
Script.make ["configuration"; name] ~description (fun ~root ->
Script.make ["configuration"; name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
let open Arg in
describe_option_and_usage ()
in
let opts = describe_option_and_usage () in
parse opts (fun ~anon describe ->
deal_with_describe describe
[ Elist.iter anon ~f:(fun name ->
Expand All @@ -718,7 +713,7 @@ module Start_script = struct
end)

let make ~env () =
Script.make [name] ~description (fun ~root ->
Script.make [name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
Expand Down Expand Up @@ -777,14 +772,11 @@ module Configuration_display_script = struct
end)

let make ~env () =
Script.make ["configuration"; name] ~description (fun ~root ->
Script.make ["configuration"; name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
let open Arg in
describe_option_and_usage ()
in
parse opts (fun ~anon describe ->
let opts = describe_option_and_usage () in
parse opts (fun ~anon:_ describe ->
let path = Environment.configuration_path env in
deal_with_describe describe
[ say "Configuration path: %s" [path]
Expand Down Expand Up @@ -815,14 +807,11 @@ module Configuration_destroy_script = struct
end)

let make ~env () =
Script.make ["configuration"; name] ~description (fun ~root ->
Script.make ["configuration"; name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
let open Arg in
describe_option_and_usage ()
in
parse opts (fun ~anon describe ->
let opts = describe_option_and_usage () in
parse opts (fun ~anon:_ describe ->
let path = Environment.configuration_path env in
deal_with_describe describe
[ say "Configuration path: %s" [path]
Expand Down Expand Up @@ -857,15 +846,15 @@ module Attach_script = struct
; fail "STOPPING" ] ] ]

let make ~env () =
Script.make [name] ~description (fun ~root ->
Script.make [name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
let open Arg in
flag ["--create"] ~doc:"Create if it doesn't exist."
& describe_option_and_usage ()
in
parse opts (fun ~anon create describe ->
parse opts (fun ~anon:_ create describe ->
deal_with_describe describe [go env create] ) )
end

Expand All @@ -877,7 +866,7 @@ module Kill_script = struct
end)

let make ~env () =
Script.make [name] ~description (fun ~root ->
Script.make [name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
Expand Down Expand Up @@ -927,7 +916,7 @@ module Logs_script = struct
end)

let make ~env () =
Script.make [name] ~description (fun ~root ->
Script.make [name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
Expand Down Expand Up @@ -986,15 +975,15 @@ module Status_script = struct
end)

let make ~env () =
Script.make [name] ~description (fun ~root ->
Script.make [name] ~description (fun ~root:_ ->
let open Gedsl in
let open Command_line in
let opts =
let open Arg in
flag ["--short"; "-s"] ~doc:"Don't output a ton of info"
& describe_option_and_usage ()
in
parse opts (fun ~anon short describe ->
parse opts (fun ~anon:_ short describe ->
let prefix_output = exec ["sed"; "s/^/ | /"] in
deal_with_describe describe
[ if_seq (Screen.is_on env)
Expand Down Expand Up @@ -1119,7 +1108,7 @@ module Example_script = struct
(List.map example ~f:(fun s ->
printf (str " %s\\n") [str s] )) ]
in
parse opts (fun ~anon run example describe ->
parse opts (fun ~anon:_ run example describe ->
deal_with_describe describe
[ switch
( List.map [basic env root] ~f:(fun (n, cl) ->
Expand Down
28 changes: 13 additions & 15 deletions src/examples/vm_tester.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ module Shell_script = struct
let m =
String.map n ~f:(function
| ('0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' | '-') as c -> c
| other -> '_' )
| _ -> '_' )
in
String.sub ~index:0 ~length:40 m |> Option.value ~default:m

let path {name; content} =
let path {name; content; _} =
let hash =
Marshal.to_string content [] |> Digest.string |> Digest.to_hex
in
Expand Down Expand Up @@ -65,7 +65,6 @@ module Run_environment = struct
List.map files ~f:(function Http (url, act) as t ->
let base = local_file_name t in
let wget =
let open Shell_script in
let open Genspio.EDSL in
check_sequence
[ ("mkdir", exec ["mkdir"; "-p"; "_cache"])
Expand Down Expand Up @@ -161,7 +160,8 @@ module Run_environment = struct

let start_qemu_vm : t -> Shell_script.t = function
| { ssh_port
; vm= Qemu_arm {kernel; machine; sd_card; root_device; initrd; _} } ->
; vm= Qemu_arm {kernel; machine; sd_card; root_device; initrd; _}
; _ } ->
let open Shell_script in
let open Genspio.EDSL in
make "Start-qemu-arm"
Expand All @@ -187,7 +187,7 @@ module Run_environment = struct
; "-append"
; sprintf "console=ttyAMA0 verbose debug root=%s" root_device ]
))
| {ssh_port; vm= Qemu_amd46 {hda; ui}} ->
| {ssh_port; vm= Qemu_amd46 {hda; ui}; _} ->
(* See https://wiki.qemu.org/Hosts/BSD
qemu-system-x86_64 -m 2048 \
-hda FreeBSD-11.0-RELEASE-amd64.qcow2 -enable-kvm \
Expand All @@ -214,8 +214,7 @@ module Run_environment = struct
; "e1000,netdev=mynet0" ] ))

let kill_qemu_vm : t -> Shell_script.t = function
| {name} ->
let open Shell_script in
| {name; _} ->
let open Genspio.EDSL in
let pid = get_stdout (exec ["cat"; "qemu.pid"]) in
Shell_script.(make (sprintf "kill-qemu-%s" name))
Expand All @@ -240,8 +239,7 @@ module Run_environment = struct
~e:[printf (string "No PID file") []; exec ["false"]] ) ]

let configure : t -> Shell_script.t = function
| {name; local_dependencies} ->
let open Shell_script in
| {name; local_dependencies; _} ->
let open Genspio.EDSL in
let report = tmp_file "configure-report.md" in
let there_was_a_failure = tmp_file "bool-failure" in
Expand All @@ -268,14 +266,14 @@ module Run_environment = struct
(List.mapi cmds ~f:(fun i c -> (sprintf "config-%s-%d" name i, c)))

let make_dependencies = function
| {vm= Qemu_amd46 {hda}} -> File.make_files [hda]
| {vm= Qemu_arm {kernel; sd_card; initrd}} ->
| {vm= Qemu_amd46 {hda; _}; _} -> File.make_files [hda]
| {vm= Qemu_arm {kernel; sd_card; initrd; _}; _} ->
File.make_files
( [kernel; sd_card]
@ Option.value_map initrd ~default:[] ~f:(fun x -> [x]) )

let setup_dir_content tvm =
let {name; root_password; setup; ssh_port; vm} = tvm in
let {root_password; setup; ssh_port; _} = tvm in
let other_files = ref [] in
let dependencies = make_dependencies tvm in
let start_deps = List.map dependencies ~f:(fun (base, _, _) -> base) in
Expand Down Expand Up @@ -361,7 +359,7 @@ module Run_environment = struct
; List.map
( ("help", Some "Display this help message")
:: !help_entries ) ~f:(function
| target, None -> ""
| _, None -> ""
| target, Some doc ->
sprintf "* `make %s`: %s\n" target doc )
|> String.concat ~sep:""
Expand Down Expand Up @@ -491,7 +489,7 @@ let () =
in
let set_example arg =
match !example with
| Some s -> fail "Too many arguments (%S)!" arg
| Some _ -> fail "Too many arguments (%S)!" arg
| None ->
example :=
Some
Expand Down Expand Up @@ -535,7 +533,7 @@ let () =
let usage = sprintf "vm-tester --vm <vm-name> <path>" in
let anon arg =
match !path with
| Some s -> fail "Too many arguments (%S)!" arg
| Some _ -> fail "Too many arguments (%S)!" arg
| None -> path := Some arg
in
Arg.parse args anon usage ;
Expand Down
Loading

0 comments on commit cfa3e7a

Please sign in to comment.