pcp
[Top] [All Lists]

Re: [pcp] Fwd: PCP metrics auto-completion in the command line

To: kenj@xxxxxxxxxxxxxxxx, Roman Revyakin <rrevyakin@xxxxxxxxxx>
Subject: Re: [pcp] Fwd: PCP metrics auto-completion in the command line
From: Nathan Scott <nscott@xxxxxxxxxx>
Date: Mon, 11 May 2009 16:43:32 +1000 (EST)
Cc: pcp@xxxxxxxxxxx
In-reply-to: <374355103.4742181242024085099.JavaMail.root@xxxxxxxxxxxxxxxxxx>
----- "Ken McDonell" <kenj@xxxxxxxxxxxxxxxx> wrote:

> Interesting.
> 
> Need to dig a bit deeper, but for me it does not work correctly.

Depends how you define "correctly" I suspect.  You may be expecting
it to stop at first "."?  Not sure thats what it is designed todo...

> The auto completion list for hinv. is reported as
> hinv.cpu.bogomips  hinv.cpu.stepping  hinv.map.scsi     
> hinv.pagesize
> hinv.cpu.cache     hinv.cpu.vendor    hinv.ncpu          hinv.physmem
> hinv.cpu.clock     hinv.machine       hinv.ndisk         
> hinv.cpu.model     hinv.map.cpu_num   hinv.nfilesys    
> 
> but pminfo hinv.cpu reports
> hinv.cpu.clock
> hinv.cpu.vendor
> hinv.cpu.model
> hinv.cpu.stepping
> hinv.cpu.cache
> hinv.cpu.bogomips

All of those are listed above though.  As well as everything else
below hinv, afaict, so it looks correct to me (just, not stopping
at the next level down, but expands all below a point if there's
not "too much" matching).

> So I'm not sure where the metrics namespace info is coming from!

Its running pminfo internally ...
COMPREPLY=(`compgen -W '$(command pminfo)' $cur`)

... maybe Roman can explain how that bit works.  compgen is
a bash builtin:

       compgen [option] [word]
              Generate  possible  completion matches for word according to the
              options, which may  be  any  option  accepted  by  the  complete
              builtin  with  the exception of -p and -r, and write the matches
              to the standard output.  When using the -F or  -C  options,  the
              various  shell  variables  set  by  the  programmable completion
              facilities, while available, will not have useful values.

              The matches will be generated in the same way  as  if  the  pro‐
              grammable  completion  code  had  generated them directly from a
              completion specification with the same flags.  If word is speci‐
              fied, only those completions matching word will be displayed.

              The  return  value is true unless an invalid option is supplied,
              or no matches were generated.

Not sure what -W does.

> And with -h and/or -a, hard to see how this is going to work without
> surprises.

Those are explicitly excluded via the regexs (i.e. if those were the
last part of the command line before attempting expansion, then no
expansion is attempted, I think).

cheers.

-- 
Nathan

<Prev in Thread] Current Thread [Next in Thread>