class CircuitPatchTools::Commands::Info
Constants
- DEFAULT_OPTIONS
- FIELDS
Public Instance Methods
description()
click to toggle source
# File lib/circuit_patch_tools/commands/info.rb, line 17 def description 'show patch information' end
name()
click to toggle source
# File lib/circuit_patch_tools/commands/info.rb, line 13 def name 'info' end
run(args)
click to toggle source
# File lib/circuit_patch_tools/commands/info.rb, line 21 def run(args) options = DEFAULT_OPTIONS.dup OptionParser.new do |opts| opts.banner = <<~END #{name}: #{description} Usage: circuit-patch #{name} [options] patch1.sysex [patch2.sysex ...] Options: END opts.on('-fFIELDS', '--fields=FIELDS', 'Comma-separated list of fields to show', "Default: #{DEFAULT_OPTIONS.fetch(:fields).join(',')}", Array) do |v| options[:fields] = v end opts.on('-l', '--list', 'List available fields') do puts *FIELDS end opts.on('-h', '--help', 'Print this help') do puts opts return end end.parse!(args) args.each do |path| show_info options, path end end
Private Instance Methods
show_info(options, path)
click to toggle source
# File lib/circuit_patch_tools/commands/info.rb, line 53 def show_info(options, path) patch = Patch.open(path) metadata = FIELDS.map { |f| [f.to_s, patch.send(f)] }.to_h options.fetch(:fields).each do |k| puts "#{k}: #{metadata.fetch(k)}" end end