Class: SeccompTools::CLI::Completion
- Defined in:
- lib/seccomp-tools/cli/completion.rb
Overview
Handle 'completion' command.
Constant Summary collapse
- SUMMARY =
Summary of this command.
'Print a shell completion script.'- USAGE =
Usage of this command.
"completion - #{SUMMARY}\n\nUsage: seccomp-tools completion <bash|zsh|fish>".freeze
- SCRIPTS =
Maps a shell name to the completion script that ships with the gem.
{ 'bash' => 'seccomp-tools.bash', 'zsh' => '_seccomp-tools', 'fish' => 'seccomp-tools.fish' }.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#handle ⇒ void
Writes the completion script for the requested shell to stdout.
-
#parser ⇒ OptionParser
Define option parser.
Methods inherited from Base
Constructor Details
This class inherits a constructor from SeccompTools::CLI::Base
Instance Method Details
#handle ⇒ void
This method returns an undefined value.
Writes the completion script for the requested shell to stdout.
29 30 31 32 33 34 35 36 37 |
# File 'lib/seccomp-tools/cli/completion.rb', line 29 def handle return unless super shell = argv.shift file = SCRIPTS[shell] return CLI.show(parser.help) if file.nil? output { File.read(File.join(__dir__, '..', '..', '..', 'completions', file)) } end |
#parser ⇒ OptionParser
Define option parser.
21 22 23 24 25 |
# File 'lib/seccomp-tools/cli/completion.rb', line 21 def parser @parser ||= OptionParser.new do |opt| opt. = usage end end |