guix-devel
[Top][All Lists]
Advanced

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

Re: New ‘--list-generations’ and ‘--delete-generations’ options


From: Ludovic Courtès
Subject: Re: New ‘--list-generations’ and ‘--delete-generations’ options
Date: Sun, 08 Sep 2013 22:22:56 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Nikita Karetnikov <address@hidden> skribis:

>> I’m asking because if we do that, ‘--list-generations’ may just as well
>> print out *all* the generation records.  Users who want to select only
>> less than one-month old generations can do that with ‘recsel’, and we
>> don’t have anything more to do.
>
>> WDYT?
>
> I see recutils as an advanced option (for those who need it), not a
> replacement for the basic functionality.

Yeah, possibly.

In that case, would you suggest --list-generations=rec to specify the
recutils output format (with no filtering)?

>> OTOH, for ‘--delete-generations’ it will still be more convenient to
>> support ‘--delete-generations’.
>
> Could you rephrase?

Oops, sorry; this should read:

  OTOH for ‘--delete-generations’ it will be more convenient to support
  date-range specifications such as ‘last-month’, etc.

> I don’t understand the above.  I believe we should think from a user’s
> perspective.  One should be able to select the needed generations
> without relying on a different program.

Yes.

>>>> What about splitting it in two functions:
>
>>>>   ‘string->time-range’ → return two SRFI-19 time objects representing a
>>>>                           time interval, or #f and #f on failure
>
>>>>   ‘generation-within-time-range?’
>
>>>> Writing tests for the former will be easy.
>
>> What do you think of the separation I proposed?
>
> We have the following cases: ‘1’, ‘1,2,3’, ‘1..9’, ‘1..’, ‘..9’,
> ‘first-month’, and ‘last-month’.  It’s easy to parse the first three and
> output a list of generations without checking them.  However, you’ll
> have to check the profile in the other cases.  That’s the problem.

[...]

> I don’t understand how the ‘string->time-range’ function will help to
> solve the above problem.  There are only two time-related cases:
> ‘first-month’ and ‘last-month’.  Why do you want to return a time range
> for every case?  Could you show an example?

Sorry I think I have been sloppy.

So we want to support generation enumerations like ‘1,2,3’, ranges
(incl. open-ended ranges) like ‘1..9’, and age specifications.

For the first one, I would do a ‘string->generations’ procedure:

  "1,2,3"  ⇒ (1 2 3)
  "1..9"   ⇒ (1 2 3 4 5 6 7 8 9)
  "..9"    ⇒ (<= 9)  ; with the ‘<=’ symbol
  "1.."    ⇒ (>= 1)
  "foo"    ⇒ #f

Age specifications would only be of the kind “at least X days/months
old”.  A non-ambiguous syntax is needed, and something more flexible
than just ‘last-month’.  Let’s assume ‘string->duration’:

  "+22"    ⇒ #<time time-duration ...>   ; 22 days
  "+2w"    ⇒ #<time time-duration ...>   ; 14 days
  "+1m"    ⇒ #<time time-duration ...>   ; 30 days
  
Then one just needs to ‘filter’ all the generations that match the
specification.  This way, there are two parsing procedures, and one or
two filtering procedures.


These are just suggestions, but that seems to make more sense now.
WDYT?

Apologies for the confusion!

Thanks,
Ludo’.



reply via email to

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