git-profile icon indicating copy to clipboard operation
git-profile copied to clipboard

[Feature suggestion] Add support for Fig

Open VityaSchel opened this issue 2 years ago • 3 comments

Hi! I love your tool! Can you add integration with fig? It would greatly help to see all commands and visualize existing profiles :)

VityaSchel avatar Jul 19 '22 12:07 VityaSchel

Hello, thank you for the suggestion. Unfortunately, I am not familiar with the tool you mentioned and do not have experience integrating it. If you are willing, I would be grateful if you could set up the integration and send me a pull request. Thank you for your help and understanding.

dotzero avatar Dec 24 '22 19:12 dotzero

Coming back to this a year later, I followed this guide https://fig.io/docs/getting-started and made simple spec myself. It only supports use command and "--help", "--config" flags and uses generator for "use" command Related: https://github.com/withfig/autocomplete/pull/1974

VityaSchel avatar May 16 '23 13:05 VityaSchel

anyway here is the spec:

const profiles: Fig.Generator = {
  script: "git-profile list",
  postProcess: (output) => {
    return Array.from(output.matchAll(/^\[(.+?)\]$/gm)).map((result) => ({
      name: result[1],
      description: `Use profile "${result[1]}"`,
    }));
  },
};

const completionSpec: Fig.Spec = {
  name: "git-profile",
  description: "Switch profiles",
  subcommands: [
    {
      name: "use",
      description: "Use a profile",
      args: {
        name: "profile",
        description: "Profile you want to apply in this repository",
        generators: profiles,
      },
    },
  ],
  options: [
    {
      name: ["--help", "-h"],
      description: "Help for git-profile script",
    },
    {
      name: ["--config", "-c"],
      description: 'Config file (default "~/.gitprofile")',
    },
  ],
};

export default completionSpec;

VityaSchel avatar May 16 '23 13:05 VityaSchel