Sha256: 16e8e7697d393a09b95c608334e97b18b92258e274c669e735a74e87653cbc19
Contents?: true
Size: 1.59 KB
Versions: 23
Compression:
Stored size: 1.59 KB
Contents
require "optparse" require "yaml" require "timber" require "timber/cli/api" require "timber/cli/application" require "timber/cli/io_helper" require "timber/cli/messages" require "timber/cli/install" module Timber # @private class CLI AVAILABLE_COMMANDS = %w(install).freeze class << self attr_accessor :options def run(argv = ARGV) @options = {} global = global_option_parser commands = command_option_parser global.order!(argv) command = argv.shift if command if AVAILABLE_COMMANDS.include?(command) commands[command].parse!(argv) case command.to_sym when :install Timber::CLI::Install.run(argv.shift) end else puts "Command '#{command}' does not exist, run timber -h to "\ "see the help" exit(1) end else # Print help puts global exit(0) end end def global_option_parser OptionParser.new do |o| o.banner = "Usage: timber <command> [options]" o.on "-v", "--version", "Print version and exit" do |_arg| puts "Timber #{Timber::VERSION}" exit(0) end o.on "-h", "--help", "Show help and exit" do puts o exit(0) end o.separator "" o.separator "Available commands: #{AVAILABLE_COMMANDS.join(", ")}" end end def command_option_parser { "install" => OptionParser.new } end end end end
Version data entries
23 entries across 23 versions & 1 rubygems
Version | Path |
---|---|
timber-2.0.2 | lib/timber/cli.rb |
timber-2.0.1 | lib/timber/cli.rb |
timber-2.0.0 | lib/timber/cli.rb |