Class: Thor::ZshCompletion::Generator
- Inherits:
-
Object
- Object
- Thor::ZshCompletion::Generator
- Defined in:
- lib/thor/zsh_completion/generator.rb
Constant Summary collapse
- SUBCOMMAND_FUNCTION_TEMPLATE =
ERB.new(File.read("#{File.dirname(__FILE__)}/template/subcommand_function.erb"), nil, "-")
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#thor ⇒ Object
readonly
Returns the value of attribute thor.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(thor, name) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(thor, name) ⇒ Generator
Returns a new instance of Generator.
7 8 9 10 |
# File 'lib/thor/zsh_completion/generator.rb', line 7 def initialize(thor, name) @thor = thor @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/thor/zsh_completion/generator.rb', line 5 def name @name end |
#thor ⇒ Object (readonly)
Returns the value of attribute thor.
5 6 7 |
# File 'lib/thor/zsh_completion/generator.rb', line 5 def thor @thor end |
Instance Method Details
#generate ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/thor/zsh_completion/generator.rb', line 12 def generate # Format command information like below: # # { name: "__iterm", # options: [], # subcommands: [ # { name: "list-sessions", # description: "List name of all sessions in current terminal", # options: [], # subcommands: [], # }, # { name: "new-session", # description: "Create new session in current terminal", # options: [ # { names: ["--name", "-n"], # description: nil, # }, # ], # subcommands: [], # }, # { name: "sessions", # description: "Manage sessions by .iterm-sessions", # options: [], # subcommands: [ # { name: "start", # description: "Start all sessions if it's not started", # options: [], # subcommands: [], # } # ] # } # ] # } main = { name: "__#{name}", description: nil, options: [], subcommands: (thor), } erb = File.read("#{File.dirname(__FILE__)}/template/main.erb") ERB.new(erb, nil, "-").result(binding) end |