Class: Clian::Command::Completions

Inherits:
Object
  • Object
show all
Defined in:
lib/clian/command/completions.rb

Instance Method Summary collapse

Constructor Details

#initialize(help, global_options, arguments, &custom_completion_proc) ⇒ Completions

Returns a new instance of Completions.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/clian/command/completions.rb', line 5

def initialize(help, global_options, arguments, &custom_completion_proc)
  @help, @global_options, @arguments = help, global_options, arguments
  @custom_completion_proc = custom_completion_proc
  command_name = arguments.find {|arg| arg !~ /^-/}

  print completion_header
  print possible_subcommands(help)

  if command_name and help[command_name]
    print arguments_spec(help[command_name])
    print options_spec(help[command_name].options)
  end
  print options_spec(global_options)
end