Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fig integration #3328

Closed
2 tasks done
dirien opened this issue Aug 20, 2022 · 9 comments · Fixed by #3437
Closed
2 tasks done

Add Fig integration #3328

dirien opened this issue Aug 20, 2022 · 9 comments · Fixed by #3437
Assignees
Labels
enhancement New feature or request

Comments

@dirien
Copy link
Contributor

dirien commented Aug 20, 2022

Is your feature request related to a problem? Please describe.

This enhancement will be in two steps:

  1. Add Fig autocomplete function with the suggested way described here -> https://fig.io/docs/guides/integrating/getting-started

  2. Will introduce the autopush function for the goreleaser spec in the fig autocomplete repository -> https://fig.io/docs/guides/integrating/push-to-autocomplete-action

Describe the solution you'd like

Full automatic creation of the fig spec

Describe alternatives you've considered

Currently I created the Spec by hand -> withfig/autocomplete#1096

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@dirien dirien added enhancement New feature or request triage Issue pending triage by one of the maintainers labels Aug 20, 2022
@caarlos0
Copy link
Member

can't goreleaser users do something like goreleaser completion fig >somepath like all other completions?

I really dislike having a PR for this every time I change anything, even if its automated... seems backwards, to say the least

caarlos0 pushed a commit that referenced this issue Aug 22, 2022
This PR releates to #3328 and fix the first part of the doings in the issue
@dirien
Copy link
Contributor Author

dirien commented Aug 22, 2022

Good question, maybe need to ask @fedeci for help! Maybe I missed a part in the integration guide!

@fedeci
Copy link

fedeci commented Aug 26, 2022

Thanks for the ping @dirien!
Hi @caarlos0, the PR is created against the withfig/autocomplete repo so apart from having an action running here (e.g. when you release a new version) everything would be handled by the fig team.

Of course the integration can be used as you mean. Essentially we expose two main methods:

  • An "high-level" one that automatically adds the "generate-fig-spec" command to your cli so that when you run "goreleaser generate-fig-spec" it prints the completion file
  • A "low-level" that instead of doing everything mentioned above just takes as input your root command and returns a stringified spec

We can bind the second one to "goreleaser completion fig" in the github action use it easily.

@caarlos0
Copy link
Member

ok, so, is it possible to run goreleaser completion fix >somepath, and fig would pick that up?

if so, which path?

@dirien
Copy link
Contributor Author

dirien commented Sep 12, 2022

I started to implement the "high level" version so is the "low level" version better as not inversive to the code base? How does the "low level" works? Any link to the docs, as I could find this in the current docs. But maybe it's me and i searched for the wrong subject!

@fedeci
Copy link

fedeci commented Sep 16, 2022

@caarlos0 Fig does not pick local paths for specs but we rely on specs being served from a cdn, so everything that we want to be public needs to be pushed to the https://github.com/withfig/autocomplete repo.
goreleaser completion fig > foo.ts would only enable the generation of specs. Eventually this can be extended using this GH action: https://fig.io/docs/guides/integrating/push-to-autocomplete-action

@fedeci
Copy link

fedeci commented Sep 16, 2022

@dirien the high level is the CreateCompletionSpecCommand export while the low level one is GenerateCompletionSpec. The first one creates a cobra command naming it generate-fig-spec, while the second one accepts the root cobra command as argument and returns a string.

This code should work:

var cmd = &cobra.Command{
	Use: "completion",
}
cmd.AddCommand(cobracompletefig.CreateCompletionSpecCommand(cobracompletefig.Opts {
	Use: "fig"
}))

@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Oct 5, 2022
@caarlos0 caarlos0 linked a pull request Oct 5, 2022 that will close this issue
caarlos0 added a commit that referenced this issue Oct 5, 2022
closes #3328

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
@caarlos0
Copy link
Member

caarlos0 commented Oct 5, 2022

refs withfig/autocomplete#1584

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants