mklabs / tabtab

tab completion helpers, for node cli programs & others. Inspired by npm completion
MIT License
364 stars 39 forks source link

yo completion unreliable #21

Open binduwavell opened 8 years ago

binduwavell commented 8 years ago

I have yo 1.8.1 installed with completions installed in zsh and bash. The following results are the same for both zsh and bash.

I type 'yo ' and hit tab. I hope to receive flags and generators. Mostly I receive nothing. At some point if I keep pressing tab I may receive flags for yo (like --generators, --help and then\[object Object\]). If I accidentally hit tab again that goes away and I have nothing... I don't know if there is a timeout issue or something else...

I have never gotten the autocompletion to return generators or sub-generators

I have the following generators installed:

generator-generator generator-nm binduwavell/generator-alfresco

The first two are installed normally with npm, the last is local and I have run npm install and npm link to get it "installed". I did try unlinking this and had the same results.

binduwavell commented 8 years ago

Not sure if it helps, I enabled TABTAB_DEBUG per the docs and noticed data being written to a cache.json file. I deleted that file and performed a couple completions yo alf<tab> returned no results. yo <tab> returned the regular flags for yo and that weird \[object Object\] thing. Here is the resulting cache.json:

{
  "timestamp": 1463446897140,
  "cache": {
    "yo alf": {
      "timestamp": 1463446886324,
      "value": [
        "-f",
        "--force",
        "--version",
        "--no-color",
        "--no-insight",
        "--insight",
        "--generators"
      ]
    },
    "yo ": {
      "timestamp": 1463446897139,
      "value": [
        {
          "name": "--force",
          "description": "Overwrite files that already exist"
        },
        {
          "name": "--version",
          "description": "Print version"
        },
        {
          "name": "--no-color",
          "description": "Disable colors"
        },
        {
          "name": "-f",
          "description": "Overwrite files that already exist"
        }
      ]
    }
  }
}
binduwavell commented 8 years ago

I did not notice anything else interesting in the debug output, here is a snippet of the file:

Received -f,--force,--version,--no-color,--no-insight,--insight,--generators
Emit evt: alfre
Emit evt: yo
Received -f,--force,--version,--no-color,--no-insight,--insight,--generators
Emit evt: alfres
Emit evt: yo
Received -f,--force,--version,--no-color,--no-insight,--insight,--generators
Emit evt: alfresco
Emit evt: yo
Received [object Object],[object Object]
Received -f,--force,--version,--no-color,--no-insight,--insight,--generators
Emit evt: alfresco
Emit evt: yo
Received [object Object],[object Object]
Received -f,--force,--version,--no-color,--no-insight,--insight,--generators
Emit evt: alfresco:amp
Emit evt: yo
Received -f,--force,--version,--no-color,--no-insight,--insight,--generators
Emit evt: alfresco:amp
Emit evt: alfresco:amp
Emit evt: yo
Received [object Object],[object Object],[object Object],[object Object]
Zsh shell detected
Installing completion script to stdout directory
Received -f,--force,--version,--no-color,--no-insight,--insight,--generators
Emit evt: yo
mklabs commented 8 years ago

Thanks a lot for your feedback.

The cache file seems correct, initially I suspected an issue there but seems fine.

I think this is due to generators namespace (the alfresco:amp), and zsh maybe understanding it as a description.

The fish shell script handles it with that node eval (https://github.com/mklabs/node-tabtab/blob/master/scripts/fish.sh#L8), I think we need to update zsh / bash scirpts to do the same.

Will test it further and keep you posted.

mklabs commented 8 years ago

Making good progress @binduwavell

The issue with

Received [object Object],[object Object],[object Object],[object Object]

in the debug output is related to the logger. I added a commit that JSON.stringify every non string argument.

I reworked the zsh script to use _describe method to try to fix #19

Physium commented 8 years ago

glad to see a similar issue here (am on OSX, EL Captian with Bash) and its in process of being fix!

Not sure if this is the right place to post this but I would just like to check if does npm uninstall -g yo automatically uninstall and remove the completion bash script path from .bashrc?

mklabs commented 8 years ago

does npm uninstall -g yo automatically uninstall and remove the completion bash script path from .bashrc

Not not yet, that's however what the yeoman/yo#442 PR is aiming to do.

For now, you'd need to manually remove these lines from your ~/.bashrc