summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2018-07-20 19:19:18 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2018-07-20 19:19:18 +0200
commitce3db61a27f2c1ca234c2270c42658f23d691a75 (patch)
tree6911ec5bf09c51626fae36c7434b32542468547b
parent44f6ff428da95cc1d9e65ef0294a538155d4722a (diff)
downloadcontext-mirror-bot-ce3db61a27f2c1ca234c2270c42658f23d691a75.tar.gz
drop unnecessary job type
-rw-r--r--context_mirror_bot.ml34
1 files changed, 14 insertions, 20 deletions
diff --git a/context_mirror_bot.ml b/context_mirror_bot.ml
index 9c0fc97..62ef5e0 100644
--- a/context_mirror_bot.ml
+++ b/context_mirror_bot.ml
@@ -668,12 +668,6 @@ let handle_zipball = function
* job dispatch
*****************************************************************************)
-type job = {
- mutable kind : job_kind;
-}
-and job_kind = Action of action | Nop
-and action = string * (unit -> unit)
-
let usage = Printf.sprintf "Usage:
%s [ --check | --status | --update ]
" Sys.argv.(0)
@@ -798,8 +792,8 @@ let run_push () =
let run_files () = Git.install_files ()
let dispatch_job = function
- | Nop -> print_endline usage
- | Action (descr, act) ->
+ | None -> print_endline usage
+ | Some (descr, act) ->
begin
log_info (Printf.sprintf
"started in %s mode at %s."
@@ -813,20 +807,20 @@ let dispatch_job = function
*****************************************************************************)
let parse_argv () =
- let j : job = { kind = Nop; } in
+ let job = ref None in
Arg.parse [
- ("--check", Arg.Unit (fun () -> j.kind <- Action ("status" , run_status ); ()), "check source timestamps");
- ("--status", Arg.Unit (fun () -> j.kind <- Action ("check" , run_check ); ()), "print status of local repo");
- ("--update", Arg.Unit (fun () -> j.kind <- Action ("update" , run_update ); ()), "update from sources");
- ("--sync", Arg.Unit (fun () -> j.kind <- Action ("sync" , run_sync ); ()), "sync local repo");
- ("--prepare", Arg.Unit (fun () -> j.kind <- Action ("prepare" , run_prepare ); ()), "prepare local repository");
- ("--download", Arg.Unit (fun () -> j.kind <- Action ("download", run_download); ()), "download source packages");
- ("--clean", Arg.Unit (fun () -> j.kind <- Action ("cleanup" , run_cleanup ); ()), "remove leftover files");
- ("--push", Arg.Unit (fun () -> j.kind <- Action ("push" , run_push ); ()), "push to mirror");
- ("--files", Arg.Unit (fun () -> j.kind <- Action ("files" , run_files ); ()), "install config and wrapper files");
+ ("--check", Arg.Unit (fun () -> job := Some ("status" , run_status ); ()), "check source timestamps");
+ ("--status", Arg.Unit (fun () -> job := Some ("check" , run_check ); ()), "print status of local repo");
+ ("--update", Arg.Unit (fun () -> job := Some ("update" , run_update ); ()), "update from sources");
+ ("--sync", Arg.Unit (fun () -> job := Some ("sync" , run_sync ); ()), "sync local repo");
+ ("--prepare", Arg.Unit (fun () -> job := Some ("prepare" , run_prepare ); ()), "prepare local repository");
+ ("--download", Arg.Unit (fun () -> job := Some ("download", run_download); ()), "download source packages");
+ ("--clean", Arg.Unit (fun () -> job := Some ("cleanup" , run_cleanup ); ()), "remove leftover files");
+ ("--push", Arg.Unit (fun () -> job := Some ("push" , run_push ); ()), "push to mirror");
+ ("--files", Arg.Unit (fun () -> job := Some ("files" , run_files ); ()), "install config and wrapper files");
("--verbose", Arg.Unit (fun () -> set_verbosity 1; ()), "enable verbose output");
] (fun a -> print_endline ("unexpected argument: "^a); exit 0) usage;
- j
+ !job
(******************************************************************************
* main
@@ -835,7 +829,7 @@ let parse_argv () =
let () =
let job = parse_argv () in
Git.set_path repo_dir;
- dispatch_job job.kind;
+ dispatch_job job;
log_info (Printf.sprintf
"mirror bot finished in %.2f s."
(Unix.gettimeofday () -. t_start));