gnu-arch-users
[Top][All Lists]
Advanced

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

Re: [Gnu-arch-users] Fai update: now with shell mode


From: Jan Hudec
Subject: Re: [Gnu-arch-users] Fai update: now with shell mode
Date: Wed, 28 Jul 2004 15:22:22 +0200
User-agent: Mutt/1.5.6+20040523i

On Wed, Jul 28, 2004 at 08:54:13 -0400, Aaron Bentley wrote:
> Jan Hudec wrote:
> >Could there be a "complete" subcommand, that would allow non-interactive
> >call to the completion engine?
> 
> Yes, I think it should have that.  Right now, the code's a bit messy, 
> and there's no "engine", just mostly-separe
> 
> >It would allow easy implementation of
> >completion in shell, possibly emacs etc.
> 
> Fai's not really suitable for scripting at the moment, so while shell 
> would make sense, I'm not sure about emacs.
> 
> > [description of command]
> Looks reasonable.  I don't know that I'll have any prefixes, though.
> 
> I suppose you might also want to be able to do "complete --source-files" 
>  or "complete --command".

No, I don't really think there is a reason for such options, because to
complete source files, the shell completion function will just call
inventory. The call to the complete command would be like:
$ fai complete ''

<list-of-all-commands>
$ fai complete 'g'

gen-sig
get
get-changeset
get-diff
grab
$ fai complete 'get' '-'

-changeset
-diff
--archive
--cache
--no-pristine
--link
--library
--sparse
--non-sparse
--silent
--no-greed-add
--unescaped
$ fai complete 'get' 'aaron'

address@hidden/
$ fai complete 'get' 'address@hidden/'
address@hidden/
aba
festival-gaim
pyaba
snapshot-tla
tla
tlasrc
fai
hackerlab
pyarch
test
tlacontrib     

(the last one is reason for the 'prefix' -- so you don't have to repeat
archive, category, etc. when completing revisions...)

> >>I haven't sorted out how to handle completion for external (aba) 
> >>commands, and I hope to have native replacements for all tla commands, 
> >>eventually.
> >
> >
> >Obviously, you can't complete arguments to a command, when you don't
> >know what arguments they have. Perhaps if they had some special
> >subcommand, say 'grammar', that gave you spec for the completion...
> 
> Yeah, one way would be:
> package-versions [--library] [--full] [--revisions] ARCHIVE

It's actualy a regular expression on tokens. So I would say:
package-versions ('--library'|'--full'|'--revisions')* <archive>
This is less human-readable, but more computer-readable.

> I'd also like to specify the output format at the same time, but maybe 
> I'm getting ahead of myself.

Hm, a bit harder, yes.

Actualy, have you seen perl6 "regular" expressions? They would be
answer for both. They are quite readable and incredibly flexible
(I quoted "regular", since they are no longer regular expressions --
they look quite like BNF, they parse arbitrary context grammars and are
turing-complete by inclusion of arbitrary code). It might not be that
long before parrot runs python and then they should be available.

In fact, the above example would look like:
<t:package-versions> (<opt:library>|<opt:full>|<opt:revisions>)* <archive>

And since the rules have arbitrary subroutines behind them, just
matching that pattern agains the command-line would generate the list of
possible matches.

> >Just gave it a try and got:
> >/home/bulb/src/fai/aba/commands/apply-changeset: 16: Syntax error: Bad 
> >substitution
> 
> >The line in question is:
> >if [ "${1:0:1}" = "-" ] ; then
> >
> >It has to be written as:
> >if expr "$1" : "-"; then
> >
> >or the first line has to be:
> >#!/bin/bash
> 
> Ah.  I'll apply that fix.

Please test it a bit, though.

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec 
<address@hidden>

Attachment: signature.asc
Description: Digital signature


reply via email to

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