Sha256: 784a96148ddb179766ebe684097d17ed0f6c4f327d57e903a52de2b84ff6c69c
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
#!/usr/bin/env ruby require "rbnotes" include Rbnotes class App def initialize @gopts = {} end def options @gopts end def parse_global_options(args) while args.size > 0 arg = args.shift case arg when "-c", "--conf" file = args.shift raise ArgumentError, args.unshift(arg) if file.nil? file = File.expand_path(file) raise ArgumentError, "no such file: %s" % file unless FileTest.exist?(file) @gopts[:conf_file] = file when "-v", "--version" args.clear args.unshift("version") break when "-h", "--help" args.clear args.unshift("help") break else args.unshift(arg) break end end end def run(args) cmd = args.shift Commands.load(cmd).execute(args, Rbnotes.conf(@gopts[:conf_file])) end end app = App.new begin app.parse_global_options(ARGV) app.run(ARGV) rescue Errno::EPIPE => e # Fix issue #61: When the pipeline which rbnotes connects is # discarded by the other program, the execption was raised. It does # not end abnormally for rbnotes. So, just ignores the exception. exit 0 rescue MissingArgumentError, MissingTimestampError, NoEditorError, ProgramAbortError, Textrepo::InvalidTimestampStringError, InvalidTimestampPatternError, ArgumentError, Errno::EACCES => e puts e.message exit 1 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rbnotes-0.4.10 | exe/rbnotes |