-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmosbot
executable file
·65 lines (57 loc) · 1.28 KB
/
mosbot
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env ruby
require 'mosbot'
# setup environment
MOS_BOT_CONF = ENV['MOS_BOT_CONF'] || "#{ENV['HOME']}/.mosbot.conf"
if File.exists?(MOS_BOT_CONF) then
File.readlines(MOS_BOT_CONF).each do |line|
if line.start_with? "#" then
next
else
key, value = line.split "="
ENV[key] = value.strip
end
end
end
# variables
type = 'doc'
id = '0'
# grab command line options
if ARGV.empty? || ARGV.length < 2
type='help'
else
ARGV.each do |arg|
case arg
# parameter is a an id
when /^[0-9]+(\.)?([0-9])?/
id = arg
when "doc"
type = 'doc'
when "bug"
type = 'bug'
when "patch"
type = 'patch'
when "idea"
type = 'idea'
when "sr"
type = 'sr'
when "-o"
ENV['MOS_OPEN_URL']="true"
when "-c"
ENV['MOS_COPY_URL']="true"
when " ", "help", "-h", "--help", "/?"
type='help'
end
end
end
# constants
OS_CONST = os
MOS_COPY_URL = ENV['MOS_COPY_URL'] || "false"
MOS_OPEN_URL = ENV['MOS_OPEN_URL'] || "false"
if type == "help" || id == "0"
display_help()
else
mosurl = generate_url(type, id)
mospuburl = generate_public_url(id)
page_title = get_title(mospuburl)
handle_output(mosurl, page_title)
end