~jonsterling/forester-devel

forester: opt forester arg v1 APPLIED

Jinser Kafka: 3
 opt forester arg
 fix `query taxon [TAXON..]`
 support `query tag [TAG..]` to query tag

 3 files changed, 18 insertions(+), 10 deletions(-)
This patch looks reasonable, I am applying it with a few small 
modifications.

Best,
Jon

P.S. It is helpful if you only include a single patch (or at least 
closely related patches) in one patch set, and if you include some prose 
description of the purpose of the patch. Also, keep in mind that we like 
to discuss changes on the forester-devel mailing list first in order to 
ensure that your time is used as efficiently as possible.
I have applied this patch, with some change to make the behaviour 
consistent when the empty list is supplied (as with the taxa).

Best,
Jon
Oh sorry. This is my first time using git-send-email and I think I
caused some confusion. Thanks for the heads up :)
When I applied the patch, I subsequently changed the above behaviour to 
not special case the empty list, as I felt the proposed behaviour was 
somehow inconsistent. I’m open to discussion, but the commandline 
query interface is likely to significantly change in the future, so we 
might perhaps save it until the full design is happening.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~jonsterling/forester-devel/patches/53496/mbox | git am -3
Learn more about email & git

[PATCH forester 1/3] opt forester arg Export this patch

---
 bin/forester/main.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/forester/main.ml b/bin/forester/main.ml
index ad72395..8b5bb4f 100644
--- a/bin/forester/main.ml
@@ -214,7 +214,7 @@ theme = "theme"                      # The directory in which your theme is stor

let arg_config =
  let doc = "A TOML file like $(i,forest.toml)" in
  Arg.(value & pos 0 file "forest.toml" & info [] ~docv:"FOREST" ~doc)
  Arg.(value & opt non_dir_file "forest.toml" & info ["f"; "forest"] ~docv:"FOREST" ~doc)

let build_cmd ~env =
  let arg_dev =
-- 
2.44.0

[PATCH forester 2/3] fix `query taxon [TAXON..]` Export this patch

use TAXON.. to filter forest
---
 bin/forester/main.ml | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/bin/forester/main.ml b/bin/forester/main.ml
index 8b5bb4f..36f56ed 100644
--- a/bin/forester/main.ml
@@ -91,7 +91,7 @@ let complete ~env config_filename title =
  completions |> Seq.iter @@ fun (addr, title) ->
  Format.printf "%s, %s\n" addr title

let query_taxon ~env taxon config_filename =
let query_taxon ~env filter_taxa config_filename =
  let config = Forester_frontend.Config.parse_forest_config_file config_filename in
  let forest =
    Forest.plant_forest @@
@@ -99,7 +99,10 @@ let query_taxon ~env taxon config_filename =
    make_dirs ~env config.trees
  in
  let taxa = Forest.taxa ~forest in
  taxa |> Seq.iter @@ fun (addr, taxon) ->
  (match filter_taxa with
  | [] -> taxa
  | ts -> taxa |> Seq.filter (fun (_, taxon) -> List.mem taxon ts))
  |> Seq.iter @@ fun (addr, taxon) ->
  Format.printf "%s, %s\n" addr taxon

let query_tag ~env config_filename =
@@ -301,13 +304,12 @@ let complete_cmd ~env =
  Cmd.v info Term.(const (complete ~env) $ arg_config $ arg_title)

let query_taxon_cmd ~env =
  let arg_taxon =
    Arg.non_empty @@ Arg.pos_all Arg.file [] @@
    Arg.info [] ~docv:"TAXON"
  let arg_taxa =
      Arg.(value @@ pos_all string [] @@ info [] ~docv:"TAXON")
  in
  let doc = "List all trees of taxon TAXON" in
  let info = Cmd.info "taxon" ~version ~doc in
  Cmd.v info Term.(const (query_taxon ~env) $ arg_taxon $ arg_config)
  Cmd.v info Term.(const (query_taxon ~env) $ arg_taxa $ arg_config)

let query_tag_cmd ~env =
  let doc = "List all trees with tag TAG" in
-- 
2.44.0
This patch looks reasonable, I am applying it with a few small 
modifications.

Best,
Jon

P.S. It is helpful if you only include a single patch (or at least 
closely related patches) in one patch set, and if you include some prose 
description of the purpose of the patch. Also, keep in mind that we like 
to discuss changes on the forester-devel mailing list first in order to 
ensure that your time is used as efficiently as possible.

[PATCH forester 3/3] support `query tag [TAG..]` to query tag Export this patch

query tree that have all TAGs
---
 bin/forester/main.ml | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/bin/forester/main.ml b/bin/forester/main.ml
index 36f56ed..734af1e 100644
--- a/bin/forester/main.ml
@@ -105,7 +105,7 @@ let query_taxon ~env filter_taxa config_filename =
  |> Seq.iter @@ fun (addr, taxon) ->
  Format.printf "%s, %s\n" addr taxon

let query_tag ~env config_filename =
let query_tag ~env filter_tags config_filename =
  let config = Forester_frontend.Config.parse_forest_config_file config_filename in
  let forest =
    Forest.plant_forest @@
@@ -113,7 +113,10 @@ let query_tag ~env config_filename =
    make_dirs ~env config.trees
  in
  let tags = Forest.tags ~forest in
  tags |> Seq.iter @@ fun (addr, tags) ->
  (match filter_tags with
  | [] -> tags
  | ts -> tags |> Seq.filter (fun (_, tags) -> List.(for_all (fun t -> mem t tags) ts)))
  |> Seq.iter @@ fun (addr, tags) ->
  let rec tag_string = function
    | [] -> ""
    | hd :: tl -> ", " ^ hd ^ tag_string tl
@@ -312,9 +315,12 @@ let query_taxon_cmd ~env =
  Cmd.v info Term.(const (query_taxon ~env) $ arg_taxa $ arg_config)

let query_tag_cmd ~env =
  let arg_tags =
      Arg.(value @@ pos_all string [] @@ info [] ~docv:"TAG")
  in
  let doc = "List all trees with tag TAG" in
  let info = Cmd.info "tag" ~version ~doc in
  Cmd.v info Term.(const (query_tag ~env) $ arg_config)
  Cmd.v info Term.(const (query_tag ~env) $ arg_tags $ arg_config)

let query_all_cmd ~env =
  let doc = "List all trees in JSON format" in
-- 
2.44.0
I have applied this patch, with some change to make the behaviour 
consistent when the empty list is supplied (as with the taxa).

Best,
Jon