It's not clear to me whether you want to use npm's completion code directly, or you just need a list of package names. If the former, 'npm completion' will provide you with the initial script, but each command (e.g. install) has its own completion function too. If the latter, this will give you the list as a JSON array:
curl http://registry.npmjs.org/-/short This is, in effect, how 'npm install' gets its package names for completion. -- Martin Cooper On Tue, Dec 25, 2012 at 9:05 AM, Xananax <[email protected]> wrote: > I am trying to do a universal installer to have a single-entry point to > install everything. > For now it only uses apt-get and npm, but I intend to add ruby, > composer/pear, etc > My code is available on pastie: http://pastie.org/5576471 > > Basically allows to do: > "inst inkscape" -> "sudo apt-get install inkscape" > "inst -n express" -> "npm install express" > "inst -i inkscape" -> "apt-cache show inkscape" > "inst -in express" -> "npm show express" > > The file is used both to call the installers and to add an autocomplete > function to bash (when using the --autocomplete flag) > so calling > "source inst --autocomplete" > adds the autocomplete command > > I am having trouble getting the auto-complete to work correctly; I am not > that good at bash scripting. > Tried modifying the lines found in the bash_complete.d/npm, but it didn't > work. > An added difficulty (for me) is that: > > 1 - I need to access only the packages names, since I don't care about > completing the npm commands. > 2 - I need to strip out all flags and arguments, since a command could be > "inst --info --npm exp" (so I need to remove --info and --npm and add in > "show") > > I am aware that I could do "npm search /^$packageName" and get the > results, but it's too verbose and needs to connect, whereas the npm > auto-complete seems to be instantaneous (correct me if I am wrong?) > > I would love some help, because I am really not figuring this out. > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
