exe/coltrane in coltrane-1.0.1 vs exe/coltrane in coltrane-1.0.2

- old
+ new

@@ -1,12 +1,15 @@ #!/usr/bin/env ruby +# frozen_string_literal: true +# rubocop:disable Metrics/BlockLength + $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__)) require 'core_ext' require 'coltrane' -require 'coltrane-cli' +require 'cli' full_color_terminals = %w[iTerm.app] safe_mode_terminals = %w[Unsupported] if full_color_terminals.include?(ENV['TERM_PROGRAM']) @@ -69,13 +72,13 @@ c.option :triads, '--triads', 'Outputs triads from the scale' c.option :sevenths, '--sevenths', 'Outputs seventh chords from the scale' c.option :pentads, '--pentads', 'Outputs pentad chords from the scale' c.option :tertians, '--tertians SIZE', 'Outputs all tertian chords from the given size from the scale' c.option :chords, '--chords [SIZE]', 'Outputs all chords from given size from the scale. Leave size empty to retrieve all' - c.action do |(scale_str), flavor:'degrees', on:'text', **options| + c.action do |(scale_str), flavor: 'degrees', on: 'text', **options| scale = Coltrane::Cli::Scale.parse(scale_str) - keyword_args = {flavor: flavor, on: on } + keyword_args = { flavor: flavor, on: on } if options.include?(:triads) chords = scale.triads Coltrane::Cli::Chord.new(*chords, **keyword_args) elsif options.include?(:sevenths) chords = scale.sevenths @@ -85,15 +88,15 @@ Coltrane::Cli::Chord.new(*chords, **keyword_args) elsif options.include?(:tertians) chords = scale.tertians(options[:tertians].to_i) Coltrane::Cli::Chord.new(*chords, **keyword_args) elsif options.include?(:chords) - if options[:chords].nil? - chords = scale.all_chords - else - chords = scale.chords(options[:chords]) - end + chords = if options[:chords].nil? + scale.all_chords + else + scale.chords(options[:chords]) + end Coltrane::Cli::Chord.new(*chords, **keyword_args) else Coltrane::Cli::Scale.new(scale, **keyword_args) end end @@ -102,26 +105,26 @@ p.command(:list) do |list| list.syntax 'list [scales, flavors, instruments (used in --on options), chord-qualities]' list.description 'List information.' list.action do |(arg)| puts case arg - when 'scales' then Coltrane::Scale.known_scales - when 'flavors' then %w[marks notes intervals degrees] - when 'instruments' then %w[guitar bass ukulele piano text] - when 'chords', 'chord-qualities' then Coltrane::Qualities::CHORD_QUALITIES.keys.sort.join(' ') - end + when 'scales' then Coltrane::Scale.known_scales + when 'flavors' then %w[marks notes intervals degrees] + when 'instruments' then %w[guitar bass ukulele piano text] + when 'chords', 'chord-qualities' then Coltrane::Qualities::CHORD_QUALITIES.keys.sort.join(' ') + end end end p.command(:'find-scale') do |c| c.syntax 'find-scale --notes C-D-E-...] OR --chord Cmaj7-Db7' c.description 'finds scales with the provided --notes or --chord' c.option :notes, '--notes C-D-E', 'Find scales with those notes' c.option :chords, '--chords Cmaj7-D11', 'find scales with those chords' - c.action do |(arg), options| - options[:notes] = "#{options[:notes]}".split('-') - options[:chords] = "#{options[:chords]}".split('-') + c.action do |(_arg), options| + options[:notes] = (options[:notes]).to_s.split('-') + options[:chords] = (options[:chords]).to_s.split('-') Coltrane::Cli::Scale.find(**options) end end p.command(:'common-chords') do |c| @@ -143,18 +146,19 @@ end p.command(:help) do |c| c.description 'May give you some help.' c.syntax 'help <command> [subcommand, sub-subcommand, ...]' - c.action do |(*command_path), options| + c.action do |(*command_path), _options| if command_path.empty? puts p - return else - puts (command_path.reduce(p) do |memo, key| - memo.commands.delete(key.to_sym) - end || "\n Sorry, command found.") + puts begin + command_path.reduce(p) do |memo, key| + memo.commands.delete(key.to_sym) + end || "\n Sorry, command found." + end end end end p.command(:about) do |c| @@ -164,5 +168,7 @@ end end p.default_command(:about) end + +# rubocop:enable Metrics/BlockLength