App-orgsel

 view release on metacpan or  search on metacpan

script/orgsel  view on Meta::CPAN

     (children)
     Headline: l=2 todo=TODO
       (title)
       Text:
         Timestamp: 2020-05-26T00:00:00F "[2020-05-26 Tue]"
         Text: " create a more generic version of csv-grep or..."
       (children)
       Text: "allow perl code specified in cli to modify or..."
       FixedWidthSection: ": % firefox-mua-modify-containers -e '$_->{colo..."
       Text: "\nto delete all containers containing "
       Text: I "/test/"
       Text: " in their name:\n\n"
       FixedWidthSection: ": % firefox-mua-delete-containers -e '$_->{name..."
       Text: "\n"
       List: D(-) indent=0
         ListItem: -
           (description term)
           Text: "log"
           (children)
           Text: "\n"
           List: U(+) indent=2
             ListItem: +
               (children)
               Timestamp: 2020-06-03T00:00:00F "[2020-06-03 Wed]"
               Text: " done on firefox-mua-modify-containers (can..."
     Headline: l=2 todo=TODO prio=C "** TODO [2020-05-29 Fri] [#C] csvutils: make..."
       (title)
       Text:
         Timestamp: 2020-05-29T00:00:00F "[2020-05-29 Fri]"
         Text: " csvutils: make csv-grep-fields, a more..."
     Headline: l=2 todo=DONE
       (title)
       Text:
         Timestamp: 2020-05-29T00:00:00F "[2020-05-29 Fri]"
         Text: " csvutils: make csv-transpose (like 'td..."
       (children)
       List: D(-) indent=0
         ListItem: -
           (description term)
           Text: "log"
           (children)
           Text: "\n"
           List: U(+) indent=2
             ListItem: +
               (children)
               Timestamp: 2020-08-16T00:00:00F "[2020-08-16 Sun]"
               Text: " done\n"

Now for some selecting examples on F<todo.org>:

 # select the second-level headlines where we store the todo items (title-only)
 % orgsel todo.org 'Headline[level=2]' --node-action eval:'print $_->title->as_string,"\n"'
 [2021-06-26 Sat] SQLite::KeyValueStore::Simple: add delete function
 [2021-06-21 Mon] Perinci::CmdLine: unwanted removal of quotes?
 [2021-06-21 Mon] Config::IOD: set_value() eats comments
 [2021-06-18 Fri] Acme::CPANModules: category
 [2021-06-17 Thu] perl module: Software::Catalog::SW::rakudo::moar
 [2020-05-26 Tue] create a more generic version of csv-grep or csv-map
 [2020-05-29 Fri] csvutils: make csv-grep-fields, a more flexible form of csv-select-fields

 # when was a specific todo list last updated? (we look at log entries)
 % orgsel todo.org 'Headline[level=2][title.as_string =~ /set_value/] Timestamp:first'
 [2021-06-22]

 # how many bugs do we have?
 % orgsel todo.org 'Headline[level=2][todo_state="BUG"]' --count

 # how many bugs and other undone todo items?
 % orgsel todo.org 'Headline[level=2][is_todo is true][is_done is false]' --count

 # how many undone todo items for csvutils project?
 % orgsel todo.org 'Headline[level=1][title.as_string =~ /csvutils/] > Headline[level=2][is_todo is true][is_done is false]' --count

 # dump a particular todo item (helps visualize structure to select further)
 % orgsel todo.org 'Headline[level=2][title.as_string =~ /eats comments/]' | dump-org-structure

 # show the update log of the todo item (with the "- log ::"):
 % orgsel todo.org 'Headline[level=2][title.as_string =~ /eats comments/] > List > ListItem[desc_term.text = "log"]:parent'

 # show the update log of the todo item (without the "- log ::"):
 % orgsel todo.org 'Headline[level=2][title.as_string =~ /eats comments/] > List > ListItem[desc_term.text = "log"] + *'

 # select todo items which have been updated at least twice (by looking at
 # number of list items under "log")
 % orgsel todo.org 'Headline[level=2] > List > ListItem[desc_term.text = "log"] + *:has-min-children(2):parent:parent'

=head2 Examples using F<addressbook.org>

Example document F<addressbook.org> (you can get this from the distribution
shared file):

 #+TODO: TODO | OLD
 
 * business > tax consultants
 * business > veterinarian
 ** budi chandra                                                         :vet:
 - born :: 1981?
 - notes ::
   + moslem
   + has two kids, the older is 10yo @2012
 - address :: jl anggrek no 123, bandung
 - opening hours :: every day 07-21, also on call 24h
 - phone :: 0855 555 1234
 - log ::
   + [2012-07-30 ] dr went to our house to vaccinate bonnie
   + [2010-04-21 ] went to his clinic, bought worm tablets
 ** deni setiawan                                                        :vet:
 - notes ::
   + day-care for dogs etc at his house, but there is concern about ticks
 - address :: jl mawar 456, bandung
 - phone :: 022 5551235
 - log ::
   + [2013-09-18 Rab] entry
 * family tree > dad's side
 ** budi roland                                                     :deceased:
 ** grace shanti
 - notes ::
   + father's first aunt
   + 85 yo @2021
 - log ::
   + [2021-06-26] entry
 * family tree > mom's side
 * zzz > old
 ** OLD rudi sanusi
 - phone/whatsapp :: 0855 555 9739
 - log ::
   + [2021-06-27 Sun] mark as old
 * zzz > unorganized
 ** agus (lisa's husband)
 ** agus putra
 ** susan muliawati
 ** susi
 ** susi (ron's friend)                                                  :vet:
 - log ::
   + [2021-04-03] met her again (the 3rd time i guess?) at ron's birthday party.
     she's married now.
   + [2019-01-02] entry

Now for some selecting examples on F<addressbook.org>:

 # list contacts which have certain tag ("vet")
 % orgsel addressbook.org 'Headline[level=2][tags has "vet"]' --eval 'say $_->title->as_string'



( run in 0.824 second using v1.01-cache-2.11-cpan-fe3c2283af0 )