Sha256: d1fc6b57629975ff1033204c51a3c408158a7a64ff132ad77ab4c39a4d21b219
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
require 'optparse' class Jobim::CLI attr_reader :parser, :options def self.run!(*args, &opts) cli = Jobim::CLI.new begin cli.parse(args) cli.options rescue puts cli.help exit end end def options @options ||= { :Daemonize => false, :Dir => Dir.pwd, :Host => '0.0.0.0', :Port => 5634, :Prefix => '/', :Quiet => false } end def parser @parser ||= OptionParser.new do |o| o.banner = "Usage: jobim [OPTION]... [DIRECTORY]" o.separator "" o.separator "Specific options:" o.on("-a", "--address HOST", "bind to HOST address (default: 0.0.0.0)") do |host| options[:Host] = host end o.on "-d", "--daemonize", "Run as a daemon process" do options[:Daemonize] = true end o.on "-p", "--port PORT", "use PORT (default: 5634)" do |port| options[:Port] = port end o.on "-P", "--prefix PATH", "Mount the app under PATH" do |path| options[:Prefix] = path end o.on "-q", "--quiet", "Silence all logging" do options[:Quiet] = true end o.separator "" o.separator "General options:" o.on "-h", "--help", "Display this help message." do puts help exit end o.on "--version", "Display the version number" do options[:version] = Jobim::VERSION puts options[:version] exit end o.separator "" o.separator "Jobim home page: <https://github.com/zellio/jobim/>" o.separator "Report bugs to: <https://github.com/zellio/jobim/issues>" o.separator "" end end def parse(args) parser.parse!(args) options[:Dir] = File.expand_path(args[0]) if args.length == 1 end def help parser.to_s end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
jobim-0.4.4 | lib/jobim/cli.rb |
jobim-0.4.3 | lib/jobim/cli.rb |
jobim-0.4.2 | lib/jobim/cli.rb |
jobim-0.4.1 | lib/jobim/cli.rb |