aboutsummaryrefslogtreecommitdiff
path: root/exe/chotto
blob: 0d6116fd63ca79ce52fc3a39c37feb76fd032d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'optparse'
require_relative '../lib/chotto'

CONFIG_FILEPATH = 'chotto/config.rb'
XDG_HOME = ENV.fetch('XDG_CONFIG_HOME', "#{Dir.home}/.config")
def start_chotto(options)
  Chotto.configure do
    config.only_new = options.fetch(:only_new, false)
  end

  config_file = File.read("#{XDG_HOME}/#{CONFIG_FILEPATH}")
  instance_eval(config_file)
  eval_rules(options)
end

options = {}
OptionParser.new do |opts|
  opts.banner = 'Usage: chotto [options]'

  opts.on('-n', '--new', 'Run only for new mesages') do |v|
    options[:only_new] = v
  end
end.parse!

start_chotto(options)