mosbot 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/mosbot +24 -24
- data/lib/mosbot.rb +48 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 997bb79ddfd9d569920612e2ab08799cb6c5bc24
|
|
4
|
+
data.tar.gz: a12f64b4a760073bba6f59d65a9390990926f87d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4241b4eff6c42aed8631f7f3ae5fa420b705d24a94f0dfa0aa27d821ba1ea9c98a306fa1372cdea613943fdfcc71e0516388fce608e3307b9deaab938f90553d
|
|
7
|
+
data.tar.gz: 13a08086a71b751f559ed644b2e1952fbe2df48e4ea58abceddfd309a7a1b1db329c1103c1b457ca2442fb3e0b3660365c528c71199665e97c10893cc531a99c
|
data/bin/mosbot
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
require 'mosbot'
|
|
4
|
-
# require_relative '../lib/mosbot'
|
|
5
|
-
|
|
6
|
-
#options
|
|
7
|
-
type = ARGV.shift || "help"
|
|
8
|
-
id = ARGV.shift
|
|
9
4
|
|
|
10
5
|
# setup environment
|
|
11
6
|
MOS_BOT_CONF = ENV['MOS_BOT_CONF'] || "#{ENV['HOME']}/.mosbot.conf"
|
|
@@ -20,34 +15,39 @@ if File.exists?(MOS_BOT_CONF) then
|
|
|
20
15
|
end
|
|
21
16
|
end
|
|
22
17
|
|
|
18
|
+
# constants
|
|
19
|
+
OS_CONST = os
|
|
20
|
+
MOS_COPY_URL = ENV['MOS_COPY_URL'] || "false"
|
|
21
|
+
MOS_OPEN_URL = ENV['MOS_OPEN_URL'] || "false"
|
|
22
|
+
type = 'doc'
|
|
23
|
+
id = '0'
|
|
24
|
+
|
|
23
25
|
# grab command line options
|
|
24
26
|
ARGV.each do |arg|
|
|
25
27
|
case arg
|
|
28
|
+
# parameter is a an id
|
|
29
|
+
when /^[0-9]+(\.)?([0-9])?/
|
|
30
|
+
id = arg
|
|
31
|
+
when "doc"
|
|
32
|
+
type = 'doc'
|
|
33
|
+
when "bug"
|
|
34
|
+
type = 'bug'
|
|
35
|
+
when "patch"
|
|
36
|
+
type = 'patch'
|
|
37
|
+
when "idea"
|
|
38
|
+
type = 'idea'
|
|
26
39
|
when "-o"
|
|
27
40
|
ENV['MOS_OPEN_URL']="true"
|
|
28
41
|
when "-c"
|
|
29
42
|
ENV['MOS_COPY_URL']="true"
|
|
43
|
+
when "-h" "--help"
|
|
44
|
+
type='help'
|
|
30
45
|
end
|
|
31
46
|
end
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
MOS_COPY_URL = ENV['MOS_COPY_URL'] || "false"
|
|
36
|
-
MOS_OPEN_URL = ENV['MOS_OPEN_URL'] || "false"
|
|
37
|
-
|
|
38
|
-
case type
|
|
39
|
-
when "doc"
|
|
40
|
-
mosurl = "https://support.oracle.com/epmos/faces/DocumentDisplay?id=" + id
|
|
41
|
-
when "bug"
|
|
42
|
-
mosurl = "https://support.oracle.com/epmos/faces/BugMatrix?id=" + id
|
|
43
|
-
when "patch"
|
|
44
|
-
mosurl = "https://support.oracle.com/epmos/faces/PatchResultsNDetails?patchId=" + id
|
|
45
|
-
when "idea"
|
|
46
|
-
mosurl = "https://community.oracle.com/ideas/" + id
|
|
47
|
-
when "help"
|
|
48
|
-
mosurl = "TODO: Generate Help Screen"
|
|
48
|
+
if type == "help"
|
|
49
|
+
display_help()
|
|
49
50
|
else
|
|
50
|
-
mosurl =
|
|
51
|
+
mosurl = generate_url(type, id)
|
|
52
|
+
handle_output(mosurl)
|
|
51
53
|
end
|
|
52
|
-
|
|
53
|
-
handle_output(mosurl)
|
data/lib/mosbot.rb
CHANGED
|
@@ -20,22 +20,66 @@ def os
|
|
|
20
20
|
)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def generate_url(type, id)
|
|
24
|
+
case type
|
|
25
|
+
when "doc"
|
|
26
|
+
mosurl = "https://support.oracle.com/epmos/faces/DocumentDisplay?id=" + id
|
|
27
|
+
when "bug"
|
|
28
|
+
mosurl = "https://support.oracle.com/epmos/faces/BugMatrix?id=" + id
|
|
29
|
+
when "patch"
|
|
30
|
+
mosurl = "https://support.oracle.com/epmos/faces/PatchResultsNDetails?patchId=" + id
|
|
31
|
+
when "idea"
|
|
32
|
+
mosurl = "https://community.oracle.com/ideas/" + id
|
|
33
|
+
else
|
|
34
|
+
mosurl = "https://support.oracle.com/epmos/faces/DocumentDisplay?id=" + id
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
23
38
|
def handle_output(url)
|
|
24
39
|
puts url
|
|
40
|
+
|
|
25
41
|
if "#{MOS_COPY_URL}" == "true"
|
|
26
42
|
case "#{OS_CONST}"
|
|
27
43
|
when "macosx", "linux"
|
|
28
|
-
|
|
44
|
+
command = "echo #{url} | pbcopy"
|
|
29
45
|
when "windows"
|
|
30
|
-
|
|
46
|
+
command = "echo #{url} | clip"
|
|
31
47
|
end
|
|
48
|
+
do_cmd(command)
|
|
32
49
|
end
|
|
50
|
+
|
|
33
51
|
if "#{MOS_OPEN_URL}" == "true"
|
|
34
52
|
case "#{OS_CONST}"
|
|
35
53
|
when "macosx"
|
|
36
|
-
|
|
54
|
+
command = "open #{url}"
|
|
37
55
|
when "windows"
|
|
38
|
-
|
|
56
|
+
command = "start #{url}"
|
|
39
57
|
end
|
|
58
|
+
do_cmd(command)
|
|
40
59
|
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def do_cmd(command)
|
|
63
|
+
out = `#{command}`
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def display_help
|
|
67
|
+
puts "mosbot - a utility to generate Oracle Support URLs"
|
|
68
|
+
puts " "
|
|
69
|
+
puts "Usage:"
|
|
70
|
+
puts "mosbot <type> <id>"
|
|
71
|
+
puts " "
|
|
72
|
+
puts " <type> is one of:"
|
|
73
|
+
puts " * doc"
|
|
74
|
+
puts " * bug"
|
|
75
|
+
puts " * patch"
|
|
76
|
+
puts " * idea"
|
|
77
|
+
puts " "
|
|
78
|
+
puts " <id> is the document id, bug number, patch number or idea number"
|
|
79
|
+
puts " "
|
|
80
|
+
puts "Options:"
|
|
81
|
+
puts " -c Copy the URL to the clipboard"
|
|
82
|
+
puts " -o Open the URL in a browser"
|
|
83
|
+
puts " "
|
|
84
|
+
puts "Visit https://github.com/psadmin-io/mosbot-cli to learn how to use the configuration file."
|
|
41
85
|
end
|