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



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/twat.rb', line 46

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 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"
  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