Package: ben Version: 0.6.11 Severity: wishlist Tags: patch Hi,
the "monitor" subcommand currently requires a configuration file to read the query strings for affected, good and bad packages. If those values could be given on the commandline, then I would not have to create a temporary configuration file anymore. The attached patch series solves this problem. cheers, josch
>From 021edc6eb08f9c943fb3e23f4cc5297587d78c70 Mon Sep 17 00:00:00 2001 From: josch <[email protected]> Date: Mon, 12 May 2014 17:15:26 +0200 Subject: [PATCH 1/3] add set_config to benl_clflags --- lib/benl_clflags.ml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/benl_clflags.ml b/lib/benl_clflags.ml index ad2ad9f..bfc7b34 100644 --- a/lib/benl_clflags.ml +++ b/lib/benl_clflags.ml @@ -49,6 +49,10 @@ let get_config key = try List.assoc key !config with Not_found -> raise (Missing_configuration_item key) +let set_config key value = + let cnf = List.remove_assoc key !config in + config := (key,value)::cnf + let get_cache_file ?(name = !cache_file) () = if Sys.file_exists name then name -- 1.9.2
>From fdc9fe6bdec506710238b0c1e14c8858466b890f Mon Sep 17 00:00:00 2001 From: josch <[email protected]> Date: Mon, 12 May 2014 17:45:21 +0200 Subject: [PATCH 2/3] add parse_expression to benl_utils --- lib/benl_utils.ml | 11 +++++++++++ lib/benl_utils.mli | 2 ++ 2 files changed, 13 insertions(+) diff --git a/lib/benl_utils.ml b/lib/benl_utils.ml index cb546f9..c899701 100644 --- a/lib/benl_utils.ml +++ b/lib/benl_utils.ml @@ -40,6 +40,17 @@ let parse_control_file kind filename keep f accu = parse_control_in_channel kind base ic keep f accu end +let parse_expression expression = + let lexbuf = from_string expression in + try + Benl_parser.full_expr Benl_lexer.token lexbuf + with Benl_parser.Error -> + let pos = Lexing.lexeme_start_p lexbuf in + raise (Parsing_error + (pos.pos_fname, + pos.pos_lnum, + pos.pos_cnum-pos.pos_bol)) + let parse_config_file filename = with_in_file filename begin fun ic -> let lexbuf = from_channel ic in diff --git a/lib/benl_utils.mli b/lib/benl_utils.mli index ecde4e0..3aec701 100644 --- a/lib/benl_utils.mli +++ b/lib/benl_utils.mli @@ -29,6 +29,8 @@ val parse_control_file : ('a Package.Name.t -> 'a Package.t -> 'b -> 'b) -> 'b -> 'b +val parse_expression : string -> Benl_types.expr + val parse_config_file : string -> Benl_types.config val file_content : string -> string -- 1.9.2
>From a1f7c765f7d226c5fcd5549d2a2e73f48a991b6b Mon Sep 17 00:00:00 2001 From: josch <[email protected]> Date: Mon, 12 May 2014 17:15:50 +0200 Subject: [PATCH 3/3] add --is-affected, --is-good and --is-bad to ben_monitor --- frontends/ben_monitor.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontends/ben_monitor.ml b/frontends/ben_monitor.ml index 30e8c2d..640bb1d 100644 --- a/frontends/ben_monitor.ml +++ b/frontends/ben_monitor.ml @@ -101,6 +101,15 @@ let rec parse_local_args = function | "--template"::template::xs -> Benl_templates.load_template template; parse_local_args xs + | "--is-affected"::str::xs -> + Benl_clflags.set_config "is_affected" (Benl_utils.parse_expression str); + parse_local_args xs + | "--is-good"::str::xs -> + Benl_clflags.set_config "is_good" (Benl_utils.parse_expression str); + parse_local_args xs + | "--is-bad"::str::xs -> + Benl_clflags.set_config "is_bad" (Benl_utils.parse_expression str); + parse_local_args xs | x::xs -> x::(parse_local_args xs) | [] -> [] @@ -116,6 +125,9 @@ let help () = "--html", "Select HTML output format"; "--output|-o", "Select output file"; "--template", "Select an HTML template"; + "--is-affected", "Criteria of affected packages"; + "--is-good", "Criteria of a good package"; + "--is-bad", "Criteria of a bad package"; ] let check_media_dir base = -- 1.9.2

