[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: Jose E. Marchesi
Subject: Re: [bug-recutils] Proposal: utility to prompt for user input
Date: Tue, 20 Oct 2015 20:56:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hi Leo!
    Recently I needed to record some structured data about a collection of
    physical objects. I read about recutils a few months ago, so I decided
    to try it out. I threw together my first ever recutils record types [1]
    and made a couple scripts [2] to streamline the data entry.

    The idea of the scripts is this: for a record type, prompt the user to
    input data for each field. I usually don't like interactive programs on
    the command line, but for data entry I think they are fine.

Yes, agreed.
    What I really didn't like about my "solution" is that the fields of the
    record types end up being replicated in three different places: in the
    record descriptor in the recfile, the script's read-loop, and the
    script's invocation of recins. This is because there was no obvious way
    to access them programmatically. In this case, there were only two
    simple record types so I just handled the triplication manually but even
    at this small scale it was annoying and I kept making mistakes.
    I saw on the ML archives that people have discussed these issues before
    [3]. Has anyone come up with a better solution to this problem?
    If not, I will make a program, writerec, that is the (inexact) inverse
    of readrec. I'm not sure exactly how it will work, but the basic idea is
    that you will give it the name of a record type and a recfile, and it
    will parse the record descriptor to decide what fields the user should
    be prompted to enter.
    My initial plan is for writerec to prompt the user to enter values for
    all %allowed fields.
    Can anyone think of any special considerations to take into account?

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.

On the other hand, recinf is the tool supposed to provide
metainformation about recfiles.  It can currently emit record

... 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`

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

    Is there any reason to make it a Bash builtin like readrec or would
    it work better as a standalone program like recins, recset, etc?

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

reply via email to

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