class Ppl::Command::Completion

Attributes

completions_directory[W]

Public Instance Methods

execute(input, output) click to toggle source
# File lib/ppl/command/completion.rb, line 12
def execute(input, output)
  shell_name = require_shell_name(input)
  location = require_completion_existence(shell_name)
  output.line(File.read(location))
end
options(parser, options) click to toggle source
# File lib/ppl/command/completion.rb, line 8
def options(parser, options)
  parser.banner = "usage: ppl completion <shell>"
end

Private Instance Methods

require_completion_existence(shell_name) click to toggle source
# File lib/ppl/command/completion.rb, line 27
def require_completion_existence(shell_name)
  path = File.join(@completions_directory.path, shell_name)
  if !File.exists? path
    raise Ppl::Error::CompletionNotFound, shell_name
  end
  path
end
require_shell_name(input) click to toggle source
# File lib/ppl/command/completion.rb, line 20
def require_shell_name(input)
  if input.arguments.first.nil?
    raise Ppl::Error::IncorrectUsage, "No shell specified"
  end
  input.arguments.shift
end