Class: Twat::Twat

Inherits:
Object
  • Object
show all
Defined in:
lib/twat.rb,
lib/twat/config.rb

Instance Method Summary collapse

Instance Method Details

#cli_runObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/twat.rb', line 52

def cli_run
  begin
    opts = ArgParse.new
    actor = Actions.new
    actor.config = config
    actor.opts = opts
    actor.send(opts.options[:action])
  rescue Usage
    opts.usage
  rescue NoSuchAccount
    puts "No such account"
    opts.usage
  rescue NoDefaultAccount
    puts "No default account configured."
  rescue NoSuchCommand
    puts "No such command"
    opts.usage
  rescue NoConfigFile
    puts "No config file, create one with twat -a [user|nick]"
    opts.usage
  rescue InvalidSetOpt
    puts "There is no such configurable option"
    opts.usage
  rescue RequiresOptVal
    puts "--set must take an option=value pair as arguments"
  rescue InvalidCredentials
    puts "Invalid credentials, try reauthenticating with"
    puts "twat -a #{opts[:account]}"
  rescue ConfigVersionIncorrect
    puts "Your config file is out of date. Run with --update-config to rememdy"
  rescue InvalidBool
    puts "Invalid value, valid values are #{Options::BOOL_VALID.join("|")}"
  rescue InvalidInt
    puts "Invalid value, must be an integer"
  rescue Errno::ECONNRESET
    puts "Connection was reset by third party."
  end
end

#configObject



10
11
12
# File 'lib/twat/config.rb', line 10

def config
  @config ||= Config.new
end

#configure {|config| ... } ⇒ Object

Yields:



3
4
5
6
7
8
# File 'lib/twat/config.rb', line 3

def configure(&block)
  yield config

  # If I understand correctly, I can check over what's
  # happened here?
end