class FLACsmith::CLI::Parsers::Core
Handles parsing of Command Line Interface (CLI
) core options.
Public Class Methods
call(...)
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 14 def self.call(...) = new(...).call def initialize configuration = Container[:configuration], client: Parser::CLIENT, **dependencies super(**dependencies) @configuration = configuration @client = client end def call arguments = [] client.banner = specification.labeled_summary client.separator "\nUSAGE:\n" collate client.parse arguments configuration end private attr_reader :configuration, :client def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method } def add_encode client.on( "-e", "--encode SOURCE_DIR,TARGET_DIR", "Encode source audio as FLAC audio." ) do |paths| source_dir, target_dir = paths.split "," configuration.merge! action_encode: true, source_dir:, target_dir: end end def add_list client.on( "-l", "--list SOURCE_DIR", "List track metadata for source directory." ) do |source_dir| configuration.merge! action_list: true, source_dir: end end def add_rebuild client.on( "-r", "--rebuild SOURCE_DIR", "Rebuild track metadata for source directory." ) do |source_dir| configuration.merge! action_rebuild: true, source_dir: end end def add_version client.on "-v", "--version", "Show gem version." do configuration.merge! action_version: true end end def add_help client.on "-h", "--help", "Show this message." do configuration.merge! action_help: true end end end end
new(configuration = Container[:configuration], client: Parser::CLIENT, **dependencies)
click to toggle source
Calls superclass method
# File lib/flacsmith/cli/parsers/core.rb, line 16 def initialize configuration = Container[:configuration], client: Parser::CLIENT, **dependencies super(**dependencies) @configuration = configuration @client = client end
Public Instance Methods
add_encode()
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 38 def add_encode client.on( "-e", "--encode SOURCE_DIR,TARGET_DIR", "Encode source audio as FLAC audio." ) do |paths| source_dir, target_dir = paths.split "," configuration.merge! action_encode: true, source_dir:, target_dir: end end
add_help()
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 75 def add_help client.on "-h", "--help", "Show this message." do configuration.merge! action_help: true end end
add_list()
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 49 def add_list client.on( "-l", "--list SOURCE_DIR", "List track metadata for source directory." ) do |source_dir| configuration.merge! action_list: true, source_dir: end end
add_rebuild()
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 59 def add_rebuild client.on( "-r", "--rebuild SOURCE_DIR", "Rebuild track metadata for source directory." ) do |source_dir| configuration.merge! action_rebuild: true, source_dir: end end
add_version()
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 69 def add_version client.on "-v", "--version", "Show gem version." do configuration.merge! action_version: true end end
call(arguments = [])
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 24 def call arguments = [] client.banner = specification.labeled_summary client.separator "\nUSAGE:\n" collate client.parse arguments configuration end
collate(= private_methods.sort.grep(/add_/).each { |method| __send__ method })
click to toggle source
# File lib/flacsmith/cli/parsers/core.rb, line 36 def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method } def add_encode client.on( "-e", "--encode SOURCE_DIR,TARGET_DIR", "Encode source audio as FLAC audio." ) do |paths| source_dir, target_dir = paths.split "," configuration.merge! action_encode: true, source_dir:, target_dir: end end def add_list client.on( "-l", "--list SOURCE_DIR", "List track metadata for source directory." ) do |source_dir| configuration.merge! action_list: true, source_dir: end end def add_rebuild client.on( "-r", "--rebuild SOURCE_DIR", "Rebuild track metadata for source directory." ) do |source_dir| configuration.merge! action_rebuild: true, source_dir: end end def add_version client.on "-v", "--version", "Show gem version." do configuration.merge! action_version: true end end def add_help client.on "-h", "--help", "Show this message." do configuration.merge! action_help: true end end end