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 support for Zsh completion to beats subcommand #5761

Merged
merged 6 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di

- Support dashboard loading without Elasticseach {pull}5653[5653]
- Addition and update of the following libraries: pbkdf2, terminal, windows, unix {pull}5735[5735]
- Update the command line library cobra and add support for zsh completion {pull}5761[5761]

*Auditbeat*

Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3327,7 +3327,7 @@ THE SOFTWARE.

--------------------------------------------------------------------
Dependency: github.com/spf13/cobra
Revision: e606913c4ee45fec232e67e70105fb6c866b95d9
Revision: 1be1d2841c773c01bee8289f55f7463b6e2c2539
License type (autodetected): Apache-2.0
./vendor/github.com/spf13/cobra/LICENSE.txt:
--------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions libbeat/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ func genCompletionCmd(name, version string, rootCmd *BeatsRootCmd) *cobra.Comman
switch args[0] {
case "bash":
rootCmd.GenBashCompletion(os.Stdout)
case "zsh":
rootCmd.GenZshCompletion(os.Stdout)
default:
fmt.Printf("Unknown shell %s, only bash is available\n", args[0])
os.Exit(1)
}
},
}
Expand Down
25 changes: 25 additions & 0 deletions libbeat/tests/system/test_cmd_completion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from base import BaseTest


class TestCommandCompletion(BaseTest):
"""
Test beat completion subcommand
"""

def setUp(self):
super(BaseTest, self).setUp()

def test_bash_completion(self):
exit_code = self.run_beat(extra_args=["completion", "bash"])
assert exit_code == 0
assert self.log_contains("bash completion for mockbeat")

def test_zsh_completion(self):
exit_code = self.run_beat(extra_args=["completion", "zsh"])
assert exit_code == 0
assert self.log_contains("#compdef mockbeat")

def test_unknown_completion(self):
exit_code = self.run_beat(extra_args=["completion", "awesomeshell"])
assert exit_code == 1
assert self.log_contains("Unknown shell awesomeshell")
Loading