[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [help-recutils] Suggestions on recutils CLI
From: |
Paul Rankin |
Subject: |
Re: [help-recutils] Suggestions on recutils CLI |
Date: |
Sun, 10 May 2015 22:55:09 +1000 |
Hi Jose,
Thanks for your quick response.
> Sounds like a good idea, to make the utilities to react to the presence
> of a file called 'Recfiles' in the current directory, and also a global
> configuration file.
>
> However, what would you put in the Recfiles file?
>
> What I originally envisioned was to use directories to organize
> recfiles. The utilities could easily find the right file to open using
> the type of the record referred in the command. For example:
>
> $ echo $RECDIRS
> .:/my/database/:others/
> $ recsel -t Contact -p Name
>
> The command above would search for a file named Contact.rec in any of
> the directories in $RECDIRS...
Would the $RECDIRS approach return records from multiple recfiles sharing the
same type name, e.g. if two recfiles found in $RECDIRS had the `%rec: contact`
name would `$ recsel -t contact` return all records of the contact type from
both recfiles? I think this would be very useful.
But I think you could also cater to the user who works the other way too, so if
a user keeps multiple recfiles in a single directory, and each recfile shares
the same type structure (e.g. contact, company, log)... 90% of the time the
user may want to return results only from a main recfile, but sometimes wishes
to override this with other recfiles...
$ echo $RECFILE
/Users/Mary/Documents/main.rec
$ recsel -t contact
=> results from main.rec
$ recsel -t contact -f ~/Documents/secondary.rec
=> results from secondary.rec
> * Globally set --case-insensitive option
>
> I feel like case sensitively is the exception rather than the rule,
> hence the alias above sets the -i option whenever I call
> recsel. Another reason for a ~/.rec file?
>
> Yes, definitely. That should be configurable in a global configuration
> file. I would call the file ~/.recutilsrc tho. "rec" is too general.
Sounds great!
> * Long results could be piped through less
>
> Just a matter of convenience. I'm usually piping queries through less
> anyway, but it's usually a case of query then "oh bother" then query |
> less.
>
> Another thing that could be configurable, a pager...
More greatness.
> * Tabulated output
>
> I managed to achieve tabulated output with the following...
>
> $ recsel FILE -t TYPE | rec2csv | column -t -s ',' | tr -d \"
>
> One problem with this method is that column does not honour quoted
> input, meaning that any commas within values are treated as new
> columns.
>
> Again just a matter of convenience, it would be great to tabulated
> output with just a single -T flag?
>
> How would that compare to the existing -R?
I was meaning a flag without arguments, whereas the -R flag requires all fields
passed as arguments... unless I'm missing a way to "select all" like the MySQL
`*`?
But mainly, the -R flag makes tabulating results messy when values themselves
contain spaces, e.g.
$ recsel tmp.rec
contact: John Doe
date: 2015-05-08
method: email
notes: Asked about cats and dogs
contact: Peter
date: 2015-05-10
method: phone
$ recsel tmp.rec -R contact,date,method,notes
John Doe 2015-05-08 email Asked about cats and dogs
Peter 2015-05-10 phone
$ recsel tmp.rec -R contact,date,method,notes | column -t
John Doe 2015-05-08 email Asked about cats and dogs
Peter 2015-05-10 phone
Compare with...
$ recsel tmp.rec -p contact,date,method,notes | rec2csv | column -t -s ',' | tr
-d \"
contact date method notes
John Doe 2015-05-08 email Asked about cats and dogs
Peter 2015-05-10 phone
> * RADICAL IDEA WARNING! recutils as a single modular command
>
> Similar to the way ledger or git works, you might have...
>
> $ rec select ...
> $ rec format ...
> $ rec insert ...
>
> ...with the command as the smallest unique substring, e.g. select
> and sel would be equivalent.
>
> You are not the first suggesting that... but I really never saw the
> point of using a multiplexer command like that. What would be the
> advantage of doing so?
The main advantage I could see is user help, e.g.
$ rec
Usage: rec [OPTIONS] [COMMAND] [OPTIONS] [FILE]
Commands:
select Select and print rec data.
set Alter or delete fields in records.
insert Insert new records in a rec database.
...
$ rec help select
...
$ rec selrct
Command not recognized. Did you mean `rec select`?
etc.etc.