class Plz::Commands::Help
Public Class Methods
new(options: nil, schema: nil)
click to toggle source
@param options [Slop] @param schema [JsonSchema::Schema]
# File lib/plz/commands/help.rb, line 6 def initialize(options: nil, schema: nil) @options = options @schema = schema end
Public Instance Methods
call()
click to toggle source
Logs out help message
# File lib/plz/commands/help.rb, line 12 def call puts %<#{@options}\nExamples:\n#{links.join("\n")}> end
Private Instance Methods
links()
click to toggle source
@return [Array<String>]
# File lib/plz/commands/help.rb, line 19 def links prog_name = File.basename($0) @schema.properties.map do |target_name, schema| schema.links.select do |link| link.href && link.method && link.title end.map do |link| str = " #{prog_name} #{link.title.underscore} #{target_name}" if key = link.href[/{(.+?)}/, 1] path = CGI.unescape(key).gsub(/[()]/, "") name = path.split("/").last if property = JsonPointer.evaluate(@schema.data, path) if example = property["example"] str << " #{name}=#{example}" end end end str end end.flatten end