-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from muandane/feat/cobra
Feat/cobra
- Loading branch information
Showing
87 changed files
with
13,047 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,19 +12,17 @@ jobs: | |
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Check out code | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Set up Go | ||
uses: actions/[email protected] | ||
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.20.5' | ||
go-version: '1.21.4' | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
uses: goreleaser/goreleaser-action@v5.0.0 | ||
with: | ||
distribution: goreleaser | ||
version: ${{ env.GITHUB_REF_NAME }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
before: | ||
hooks: | ||
- ./scripts/completions.sh | ||
builds: | ||
- binary: goji | ||
main: ./cmd | ||
main: src/ | ||
goos: | ||
- darwin | ||
- linux | ||
|
@@ -12,7 +15,7 @@ builds: | |
flags: | ||
- -mod=vendor | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} | ||
- -s -w -X cmd.version={{.Version}} | ||
|
||
release: | ||
prerelease: auto | ||
|
@@ -30,6 +33,10 @@ brews: | |
commit_author: | ||
name: muandane | ||
email: [email protected] | ||
extra_install: |- | ||
bash_completion.install "completions/goji.bash" => "goji" | ||
zsh_completion.install "completions/goji.zsh" => "_goji" | ||
fish_completion.install "completions/goji.fish" | ||
checksum: | ||
name_template: 'checksums.txt' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
set -e | ||
rm -rf completions | ||
mkdir completions | ||
for sh in bash zsh fish; do | ||
go run main.go completion "$sh" >"completions/goji.$sh" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright © 2023 NAME HERE <EMAIL ADDRESS> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// completionCmd represents the completion command | ||
var completionCmd = &cobra.Command{ | ||
Use: "completion [bash|zsh|fish|powershell]", | ||
Short: "Generate completion script", | ||
Long: fmt.Sprintf(`To load completions: | ||
Bash: | ||
$ source <(%[1]s completion bash) | ||
# To load completions for each session, execute once: | ||
# Linux: | ||
$ %[1]s completion bash > /etc/bash_completion.d/%[1]s | ||
# macOS: | ||
$ %[1]s completion bash > $(brew --prefix)/etc/bash_completion.d/%[1]s | ||
Zsh: | ||
# If shell completion is not already enabled in your environment, | ||
# you will need to enable it. You can execute the following once: | ||
$ echo "autoload -U compinit; compinit" >> ~/.zshrc | ||
# To load completions for each session, execute once: | ||
$ %[1]s completion zsh > "${fpath[1]}/_%[1]s" | ||
# You will need to start a new shell for this setup to take effect. | ||
fish: | ||
$ %[1]s completion fish | source | ||
# To load completions for each session, execute once: | ||
$ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish | ||
PowerShell: | ||
PS> %[1]s completion powershell | Out-String | Invoke-Expression | ||
# To load completions for every new session, run: | ||
PS> %[1]s completion powershell > %[1]s.ps1 | ||
# and source this file from your PowerShell profile. | ||
`, rootCmd.Name()), | ||
DisableFlagsInUseLine: true, | ||
ValidArgs: []string{"bash", "zsh", "fish", "powershell"}, | ||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
switch args[0] { | ||
case "bash": | ||
rootCmd.GenBashCompletion(os.Stdout) | ||
case "zsh": | ||
rootCmd.GenZshCompletion(os.Stdout) | ||
case "fish": | ||
rootCmd.GenFishCompletion(os.Stdout, true) | ||
case "powershell": | ||
rootCmd.GenPowerShellCompletionWithDesc(os.Stdout) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(completionCmd) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.