raibo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/raibo +52 -5
  2. data/lib/raibo/version.rb +1 -1
  3. metadata +1 -1
data/bin/raibo CHANGED
@@ -2,13 +2,60 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'raibo'
5
+ require 'optparse'
6
+ require 'ostruct'
5
7
 
6
- botfile = ARGV.shift || 'Botfile'
8
+ options = OpenStruct.new
9
+ options.botfile = 'Botfile'
10
+ options.nick = 'Raibo'
11
+ options.channel = '#raibo'
12
+ options.verbose = false
7
13
 
8
- if Dir[botfile].empty?
9
- puts "Usage: raibo [botfile]"
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: raibo <server>[:<port>] [options]"
16
+
17
+ o.on("-b", "--botfile [FILE]",
18
+ "specify the location of the bot's configuration (default is \"./Botfile\")") do |file|
19
+ options.botfile = file
20
+ end
21
+
22
+ o.on("-n", "--nick [NICK]",
23
+ "specify the nick to use (default is \"Raibo\")") do |nick|
24
+ options.nick = nick
25
+ end
26
+
27
+ o.on("-c", "--channel [CHANNEL]",
28
+ "specify the channel to use (default is \"#raibo\")") do |channel|
29
+ options.channel = channel
30
+ end
31
+
32
+ o.on("-v", "--verbose", "show every incoming and outgoing line") do
33
+ options.verbose = true
34
+ end
35
+
36
+ o.on("-V", "--version", "show raibo's version") do
37
+ puts Raibo::VERSION
38
+ exit 0
39
+ end
40
+
41
+ o.on("-h", "--help", "show this message") do
42
+ puts opts
43
+ exit 0
44
+ end
45
+ end
46
+ opts.parse!(ARGV)
47
+
48
+ if ARGV.length != 1
49
+ puts opts
50
+ exit 1
10
51
  end
11
52
 
12
- b = Raibo::Bot.new('irc.he.net', :nick => 'raibot', :port => 6667, :verbose => true)
13
- b.instance_eval(File.read(botfile))
53
+ server, port = ARGV.shift.split(':')
54
+
55
+ b = Raibo::Bot.new(server,
56
+ :port => port,
57
+ :nick => options.nick,
58
+ :channel => options.channel,
59
+ :verbose => options.verbose)
60
+ b.instance_eval(File.read(options.botfile))
14
61
  b.run
@@ -1,3 +1,3 @@
1
1
  module Raibo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: raibo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Fitzgerald