Skip to content

Commit

Permalink
feat: add fig autocomplete support (#608)
Browse files Browse the repository at this point in the history
Signed-off-by: Engin Diri <[email protected]>
  • Loading branch information
Engin Diri committed Aug 20, 2022
1 parent 4f8de7e commit e699a55
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/fig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Publish minectl spec'
on:
push:
tags:
- '*'
jobs:
push-to-fig-autocomplete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3.4.1
- name: Set up Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # tag=v3.2.1
with:
go-version: 1.19
- uses: actions/cache@a7c34adf76222e77931dedbf4a45b2e4648ced19 # tag=v3.0.7
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Generate the spec
run: go mod tidy && go run . generateFigSpec > mineclt.ts

- name: Create Autocomplete PR ## Create the autocomplete PR using this action
uses: withfig/push-to-fig-autocomplete-action@74f26098865d70a99aaf2a449c705d7f9bec5ba3 # tag=v1.1.2
with:
token: ${{ secrets.GH_PAT }}
autocomplete-spec-name: minectl
spec-path: mineclt.ts
integration: cobra
9 changes: 5 additions & 4 deletions cmd/minectl/minectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
"runtime"
"strings"

"github.com/mitchellh/go-homedir"

"github.com/Azure/go-autorest/autorest/to"
"go.uber.org/zap"

"github.com/minectl/internal/logging"
cobracompletefig "github.com/withfig/autocomplete-tools/integrations/cobra"

"github.com/Azure/go-autorest/autorest/to"
"github.com/blang/semver/v4"
"github.com/minectl/internal/logging"
"github.com/mitchellh/go-homedir"
"github.com/morikuni/aec"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -294,6 +294,7 @@ func init() {
minectlCmd.AddCommand(pluginCmd)
minectlCmd.AddCommand(rconCmd)
minectlCmd.AddCommand(updateCmd)
minectlCmd.AddCommand(cobracompletefig.CreateCompletionSpecCommand())
}

func Execute(version, gitCommit, date string) error {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ require (
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
go.opencensus.io v0.23.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs=
github.com/vultr/govultr/v2 v2.17.2/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI=
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 h1:+dBg5k7nuTE38VVdoroRsT0Z88fmvdYrI2EjzJst35I=
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1/go.mod h1:nmuySobZb4kFgFy6BptpXp/BBw+xFSyvVPP6auoJB4k=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand Down

0 comments on commit e699a55

Please sign in to comment.