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

feat: update cobra #1

Merged
merged 54 commits into from
Mar 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ad6db7f
Create unit test illustrating unknown flag bug (#1854)
brianpursley Nov 15, 2022
4305498
Update stale.yml (#1863)
enrichman Nov 22, 2022
c6b9971
fix: force ForEach-Object to return array in pwsh completion (#1850)
totkeks Nov 25, 2022
6200c8e
Makefile: add target richtest (#1865)
umarcor Nov 25, 2022
7bb1440
build(deps): bump golangci/golangci-lint-action from 3.2.0 to 3.3.1 (…
dependabot[bot] Nov 26, 2022
a6f198b
Update kubescape org (#1874)
Dec 6, 2022
9235920
ci: deprecate go 1.15 (#1866)
umarcor Dec 9, 2022
f25a3c6
fix: conflict import name with variable (#1879)
yashLadha Dec 15, 2022
fdffa5a
Update badge route (#1884)
sh-cho Dec 23, 2022
bf11ab6
fix: func name in doc strings (#1885)
yashLadha Dec 25, 2022
b4f979a
completions: do not detect arguments with dash as 2nd char as flag (#…
oncilla Jan 3, 2023
4fa4fdf
build(deps): bump github.com/inconshreveable/mousetrap (#1872)
dependabot[bot] Jan 3, 2023
d022c0f
Add documentation about disabling completion descriptions (#1901)
Shihta Jan 30, 2023
8b8ee87
Improve MarkFlagsMutuallyExclusive example in User Guide (#1904)
janhn Feb 6, 2023
87ebcd8
Update shell_completions.md (#1907)
gusega Feb 9, 2023
e839bb3
build(deps): bump golangci/golangci-lint-action from 3.3.1 to 3.4.0 (…
dependabot[bot] Feb 12, 2023
a516d41
Removes stale bot from GitHub action (#1908)
jpmcb Feb 14, 2023
3daa4b9
Add keeporder to shell completion (#1903)
h4ck3rk3y Feb 25, 2023
567ea8e
Add support for PowerShell 7.2+ (#1916)
oldium Feb 25, 2023
c7300f0
ci: deprecate go 1.16 (#1926)
umarcor Mar 6, 2023
fb36524
ci: test Golang 1.20 (#1925)
umarcor Mar 6, 2023
9e6b58a
update copyright year (#1927)
umarcor Mar 6, 2023
b197a24
Update projects_using_cobra.md (#1932)
frouioui Mar 14, 2023
c8a20a1
Document suggested layout for subcommands (#1930)
lcarva Mar 17, 2023
45360a5
Allow sourcing zsh completion script (#1917)
marckhouzam Mar 22, 2023
4dd4b25
Update main image to better handle dark background (#1883)
marckhouzam Mar 22, 2023
284f410
Fix typo in fish completions (#1945)
twpayne Apr 8, 2023
0e3a0bf
build(deps): bump golangci/golangci-lint-action from 3.4.0 to 3.5.0 (…
dependabot[bot] Jun 12, 2023
2246fa8
Fix grammar: 'allows to' (#1978)
supertassu Jun 13, 2023
988bd76
test: make fish_completions_test more robust (#1980)
branchvincent Jun 16, 2023
fdee73b
powershell: escape variable with curly brackets (#1960)
Luap99 Jun 19, 2023
cbe4865
build(deps): bump golangci/golangci-lint-action from 3.5.0 to 3.6.0 (…
dependabot[bot] Jun 20, 2023
dcb405a
Move documentation sources to site/content (#1428)
umarcor Jun 20, 2023
c81c46a
Add 'one required flag' group (#1952)
marevers Jul 16, 2023
66b215b
golangci: enable 'unused' and disable deprecated replaced by it (#1983)
umarcor Jul 18, 2023
60d056d
doc: fix typo, Deperecated -> Deprecated (#2000)
callthingsoff Jul 20, 2023
fd865a4
minor corrections to unit tests (#2003)
JunNishimura Jul 23, 2023
4955da7
build(deps): bump golangci/golangci-lint-action from 3.6.0 to 3.7.0 (…
dependabot[bot] Aug 28, 2023
285460d
command: temporarily disable G602 due to securego/gosec#1005 (#2022)
umarcor Aug 29, 2023
c5dacb3
ci: test golang 1.21 (#2024)
nunoadrego Sep 8, 2023
0c72800
Customizable error message prefix (#2023)
5ouma Sep 8, 2023
bd4d165
feat: add getters for flag completions (#1943)
avirtopeanu-ionos Sep 26, 2023
95d8a1e
Add notes to doc on preRun and postRun condition (#2041)
haoming29 Oct 9, 2023
efe8fa3
build(deps): bump actions/setup-go from 3 to 4 (#1934)
dependabot[bot] Oct 15, 2023
5c962a2
build(deps): bump github.com/cpuguy83/go-md2man/v2 from 2.0.2 to 2.0.…
dependabot[bot] Oct 16, 2023
4cafa37
Allow running persistent run hooks of all parents (#2044)
vkhoroz Oct 22, 2023
8b1eba4
Fix linter errors (#2052)
marckhouzam Oct 27, 2023
b711e87
Don't complete --help flag when flag parsing disabled (#2061)
marckhouzam Oct 28, 2023
00b68a1
Add tests for flag completion registration (#2053)
marckhouzam Oct 28, 2023
22953d8
Replace all non-alphanumerics in active help env var program prefix (…
scop Oct 29, 2023
48cea5c
build(deps): bump actions/checkout from 3 to 4 (#2028)
dependabot[bot] Oct 30, 2023
890302a
Support usage as plugin for tools like kubectl (#2018)
nirs Nov 2, 2023
a0a6ae0
Improve API to get flag completion function (#2063)
marckhouzam Nov 2, 2023
bfd8d9b
feat: expose GetCompletions (was getCompletions)
gfyrag Nov 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: make fish_completions_test more robust (spf13#1980)
Use temporary files instead of assuming the current directory is
writable. Also, if creating a temporary file still returns an error,
prevent the test from failing silently by replacing `log.Fatal` with
`t.Fatal`.
  • Loading branch information
branchvincent authored Jun 16, 2023
commit 988bd76139210bc1d686c7112b4eb5e784365f1f
35 changes: 13 additions & 22 deletions fish_completions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ package cobra

import (
"bytes"
"errors"
"fmt"
"log"
"os"
"path/filepath"
"testing"
)

Expand Down Expand Up @@ -98,12 +99,12 @@ func TestFishCompletionNoActiveHelp(t *testing.T) {
}

func TestGenFishCompletionFile(t *testing.T) {
err := os.Mkdir("./tmp", 0755)
tmpFile, err := os.CreateTemp("", "cobra-test")
if err != nil {
log.Fatal(err.Error())
t.Fatal(err.Error())
}

defer os.RemoveAll("./tmp")
defer os.Remove(tmpFile.Name())

rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}
child := &Command{
Expand All @@ -113,18 +114,18 @@ func TestGenFishCompletionFile(t *testing.T) {
}
rootCmd.AddCommand(child)

assertNoErr(t, rootCmd.GenFishCompletionFile("./tmp/test", false))
assertNoErr(t, rootCmd.GenFishCompletionFile(tmpFile.Name(), false))
}

func TestFailGenFishCompletionFile(t *testing.T) {
err := os.Mkdir("./tmp", 0755)
tmpDir, err := os.MkdirTemp("", "cobra-test")
if err != nil {
log.Fatal(err.Error())
t.Fatal(err.Error())
}

defer os.RemoveAll("./tmp")
defer os.RemoveAll(tmpDir)

f, _ := os.OpenFile("./tmp/test", os.O_CREATE, 0400)
f, _ := os.OpenFile(filepath.Join(tmpDir, "test"), os.O_CREATE, 0400)
defer f.Close()

rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}
Expand All @@ -135,18 +136,8 @@ func TestFailGenFishCompletionFile(t *testing.T) {
}
rootCmd.AddCommand(child)

got := rootCmd.GenFishCompletionFile("./tmp/test", false)
if got == nil {
t.Error("should raise permission denied error")
}

if os.Getenv("MSYSTEM") == "MINGW64" {
if got.Error() != "open ./tmp/test: Access is denied." {
t.Errorf("got: %s, want: %s", got.Error(), "open ./tmp/test: Access is denied.")
}
} else {
if got.Error() != "open ./tmp/test: permission denied" {
t.Errorf("got: %s, want: %s", got.Error(), "open ./tmp/test: permission denied")
}
got := rootCmd.GenFishCompletionFile(f.Name(), false)
if !errors.Is(got, os.ErrPermission) {
t.Errorf("got: %s, want: %s", got.Error(), os.ErrPermission.Error())
}
}