Skip to content

Commit

Permalink
Merge pull request #361 from cncf/poc/tab_completion_265
Browse files Browse the repository at this point in the history
poc of tab_completion
  • Loading branch information
wvwatson authored Aug 26, 2020
2 parents 0d613f8 + 001e299 commit 401de5e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,20 @@ crystal bin/ameba.cr
crystal src/cnf-conformance.cr help
```


## Install Tab Completion

NOTE: also compatible with the styles from kubectl completion install if you prefer
https://kubernetes.io/docs/tasks/tools/install-kubectl/#enable-kubectl-autocompletion

```
./cnf-conformance completion -l error > test.sh
source test.sh
```


## Compatibility Tests

#### :heavy_check_mark: To run all of the compatibility tests
```
crystal src/cnf-conformance.cr compatibility
Expand Down
18 changes: 18 additions & 0 deletions src/cnf-conformance.cr
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,22 @@ task "test" do
puts "ping"
end

# https://www.thegeekstuff.com/2013/12/bash-completion-complete/
# https://kubernetes.io/docs/tasks/tools/install-kubectl/#enable-kubectl-autocompletion
# https://stackoverflow.com/questions/43794270/disable-or-unset-specific-bash-completion
desc "Install Shell Completion: check https://github.com/cncf/cnf-conformance/blob/master/USAGE.md for usage"
task "completion" do |_|

# assumes bash completion feel free to make a pr for zsh and check an arg for it
bin_name = "cnf-conformance"

completion_template = <<-TEMPLATE
# to remove
# complete -r #{bin_name}
complete -W "#{Sam.root_namespace.all_tasks.map(&.name).join(" ")}" #{bin_name}
TEMPLATE

puts completion_template
end

Sam.help

0 comments on commit 401de5e

Please sign in to comment.