microsoft / inshellisense

IDE style command line auto complete
MIT License
8.24k stars 181 forks source link

Generators don't seem to work #48

Closed rajyraman closed 7 months ago

rajyraman commented 8 months ago

I tried to get the most basic generator working in pwsh but no suggestions are being shown. Since dotnet package add is also using generator, I thought I will test that but no dynamic suggestions for package is being shown. So, it does not appear to work at all.

inshellisense: 0.0.1-rc.3 node: v18.18.0

cpendery commented 8 months ago

Hey @rajyraman, I don't see dotnet package as a command that's been implemented by fig (dotnet's base spec & dotnet's subcommand specs. If I try something like git add in pwsh, I'm able to see generator suggestions for the git commands.

I do see some issues with git branch, I'll investigate that

rajyraman commented 8 months ago

@cpendery - I am getting a different behaviour with add. image

const completionSpec: Fig.Spec = {
  name: "abc",
  description: "",
  subcommands: [
    {
      name: "my_subcommand",
      description: "Example subcommand",
      subcommands: [
        {
          name: "my_nested_subcommand",
          description:
            "Nested subcommand, example usage: 'abc my_subcommand my_nested_subcommand'",
        },
      ],
    },
  ],
  options: [
    {
      name: ["--branch", "-b"],
      description: "Show help for abc",
      args: {
        name: "branch",
        isScript: true,
        generators: [
          {
            script: ["git", "branch", "-l"],
            postProcess: function (out) {
              return out.split("\n").map((branch) => {
                return { name: branch, description: "branch" };
              });
            },
          },
        ],
      },
    },
  ],
  // Only uncomment if abc takes an argument
  // args: {}
};
export default completionSpec;

I don't any completions for this generator.

image

cpendery commented 8 months ago

@rajyraman where are you putting this generator? Right now, inshellisense doesn't support fig's dev mode for testing new specs.

Can you run git --no-optional-locks status --short in the same repository and provide the output?

rajyraman commented 8 months ago

@cpendery - I build my autocomplete module with yarn dev and copied the js to inshellisense withfig's build folder. I also added the module to index.js image

Below is the output of the git command. image

cpendery commented 8 months ago

You'd need to update the index.js file as well to get that to work

rajyraman commented 8 months ago

@cpendery - Yes. I was already doing that.

rajyraman commented 8 months ago

@cpendery - I already have pac working locally. Just need to add the generator bits.

https://x.com/RajYRaman/status/1722342461018984470?s=20