#!/usr/bin/env ruby require 'optparse' require 'methadone' require 'fav.rb' class App include Methadone::Main include Methadone::CLILogging include Methadone::SH main do |command_name, *command_args| cmd = Fav::CommandFactory.makeCommand(options, command_name, command_args) cmd.run! end description "A utility for organizing your commonly used shell commands. Commands are stored in ~/.favs." #Define flags on("-a COMMAND_TEXT","--add", "Add a command to the list of favorites") on("-l", "--list", "List available commands") on("-g GROUP_NAME","--group", "If used with -a flag, will add command to group. Otherwise will run command within group") on("-r","--remove", "Remove a command from the list of favorites") # # Specify switches via: on("--no_prompt", "Skip prompting when running a group of commands") # # Or, just call OptionParser methods on opts # # Require an argument arg :command_name, "Name of command", :optional # # # Make an argument optional # arg :optional_arg, :optional version Fav::VERSION @log_level = Logger::DEBUG logger.level = Logger::DEBUG go! end