Sha256: c4f09a1ec92eedb66ed898bb70dad1d33d527131fe58c5e67d3f81cf5dacfde8
Contents?: true
Size: 1.6 KB
Versions: 5
Compression:
Stored size: 1.6 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift File.join(__dir__, '..', 'lib') require 'journal-cli' require 'optparse' module Journal class << self def usage puts 'Usage: journal [type] [date]' puts puts 'Available journal types:' list_journals end def list_journals config = Journal.config puts config['journals'].keys end def run(args) if args.count.zero? puts "No journal specified" usage Process.exit 1 end journal = args.shift date = if args.length.positive? Chronic.parse(args.join(' '), future: false) else Time.now end if Journal.config['journals'].key?(journal) checkin = Journal::Checkin.new(journal, date) checkin.go else puts "Journal #{journal} not found" usage Process.exit 1 end end end end optparse = OptionParser.new do |opts| opts.banner = 'Usage: journal JOURNAL_KEY [NATURAL LANGUAGE DATE]' opts.on('-v', '--version', 'Display version') do puts "journal v#{Journal::VERSION}" Process.exit 0 end opts.on('-l', '--list', 'List available journals') do Journal.list_journals Process.exit 0 end Color.coloring = $stdout.isatty opts.on('--[no-]color', 'Colorize output') do |c| Color.coloring = c end opts.on('-h', '--help', 'Display help') do puts opts puts puts 'Available journal types:' config = Journal.config puts(config['journals'].keys.map { |k| "- #{k}" }) Process.exit 0 end end optparse.parse! Journal.run(ARGV)
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
journal-cli-1.0.22 | bin/journal |
journal-cli-1.0.21 | bin/journal |
journal-cli-1.0.20 | bin/journal |
journal-cli-1.0.19 | bin/journal |
journal-cli-1.0.18 | bin/journal |