class AudioFeedManager::CommandsList
Public Instance Methods
get(argv)
click to toggle source
# File lib/audio_feed_manager/cli/commands_list.rb, line 21 def get(argv) name, *options = *argv command = nil case name when 'init' command = initialize_project when 'publish' command = publish when 'help' command = help when 'feeds' subcommand, *options = *options name = "#{name} #{subcommand}" case subcommand when 'add' command = add_feed when 'show' command = show_feed when 'get-url' command = get_feed_url when 'update-rss' command = update_feed_rss when 'list' command = list_feeds end when 'audio' subcommand, *options = *options name = "#{name} #{subcommand}" case subcommand when 'add' command = add_audio_file end when nil command = help end raise UnknownCommand, "Unknown command: #{name}" unless command [command, options] end
print_command_usage(command_name, subcommand_name = nil)
click to toggle source
# File lib/audio_feed_manager/cli/commands_list.rb, line 75 def print_command_usage(command_name, subcommand_name = nil) command, _ = get([command_name, subcommand_name].compact) console.error "Usage: afm #{command.usage_line}" if command.has_arguments? console.error "" console.error "Arguments:" command.required_arguments.each do |arg| console.error "\t#{arg.usage_name} - #{arg.description}" end command.optional_arguments.each do |arg| console.error "\t#{arg.usage_name} (optional) - #{arg.description}" end command.varargs_arguments.each do |arg| at_least_text = arg.minimum > 0 ? "(at least #{arg.minimum}) " : "" console.error "\t#{arg.usage_name} #{at_least_text}- #{arg.description}" end end end
print_usage()
click to toggle source
# File lib/audio_feed_manager/cli/commands_list.rb, line 65 def print_usage console.error "Usage: afm <COMMAND> [options] [arguments...]" console.error "" console.error "Available commands:" console.error "" command_list.each do |command| console.error "\t#{command.name} - #{command.description}" end end
run(command_name: nil, subcommand_name: nil)
click to toggle source
# File lib/audio_feed_manager/cli/commands_list.rb, line 99 def run(command_name: nil, subcommand_name: nil) if command_name print_command_usage(command_name, subcommand_name) else print_usage end end
Private Instance Methods
command_list()
click to toggle source
# File lib/audio_feed_manager/cli/commands_list.rb, line 113 def command_list [initialize_project, add_feed, list_feeds, show_feed, update_feed_rss, get_feed_url, add_audio_file, publish, help] end
help()
click to toggle source
# File lib/audio_feed_manager/cli/commands_list.rb, line 109 def help self end