[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-recutils] Proposal: utility to prompt for user input

From: Leo Famulari
Subject: Re: [bug-recutils] Proposal: utility to prompt for user input
Date: Tue, 20 Oct 2015 16:26:41 -0400
User-agent: Mutt/1.5.24 (2015-08-30)

On Tue, Oct 20, 2015 at 08:56:06PM +0200, Jose E. Marchesi wrote:
> I always envisioned an interactive mode for recins (recins -I?) that
> would perform the task you describe.  The interactive prompt could use
> %allowed (as you hinted) but also %mandatory and the other special
> fields to improve the user interface.

How do you think the interactive mode should handle %mandatory and other
"restrictive" fields like it? Perhaps the prompt for a mandatory field
can say that it is mandatory, like this:
Enter item color (mandatory):

Do you think the interactive mode should nag the user if they fail to
satisfy the restrictions? Or just return an error and force them to
enter the record again?

I spent some time reading rec.h but I haven't completely wrapped my head
around the API yet. The very rough plan I have in my head is to try to
copy recins as much as possible: call rec_db_insert followed by
recutl_check_integrity. What do you think?

> On the other hand, recinf is the tool supposed to provide
> metainformation about recfiles.  It can currently emit record
> descriptors...
> ... but unfortunately recsel and company doesn't apply selection
> expressions to record descriptors, so, the following won't work:
> fields=`recinf -d -t machine $file | recsel -P %allowed`

If we went this route, how would we call recins in the shell script? The
"fields" shell variable would still require a lot of text processing in
order to turn this:

$ fields="name description"

...into this:

$ recins -t machine \
-f name -v $name \
-f description -v $description \

I actually thought about parsing the output of  `recinf -d`, and then
building up the recins command as text before calling the shell's `eval`
on it. That is possible currently, but it's the kind of work that I'd
rather nobody have to do.

> So, we could add selection options to recinf.  Or we could change it to
> emit record descriptors without the % prefixes.

I'm afraid I don't understand what recinf would be selecting. Can you
explain it more?

> readrec is a bash builtin because it needs to run on the shell process
> in order to set shell variables.

That's what I thought.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]