cmdr 0.3.4 → 0.4.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/cmdr.rb +62 -123
- metadata +24 -50
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cc9c9e0179e5ee5cd891cb329c477c5895279f2
|
4
|
+
data.tar.gz: 4777f73a93902ce20cb4cb70ceb0ccd9833470a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d519009145bd2756dd2c36ba30c07f237800f88c7bb1bedea656cd215ee4625b53698655af0c6e3d8d0a8f368a294cb5a08792ea86e7efc49db430ec4ae1976
|
7
|
+
data.tar.gz: 0cbe2c292533d70314783671ea45172b76c208a6492d583ea38ef3ceebbfba6e0324d383f2ad0609546471d8d649761c1f9779c0850ae5de513dd00ccc5f9f0d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cmdr.rb
CHANGED
@@ -1,152 +1,91 @@
|
|
1
|
-
#!/
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
#file: cmdr.rb
|
3
|
+
# file: cmdr.rb
|
4
4
|
|
5
|
-
require 'builder'
|
6
|
-
require 'rscript'
|
7
|
-
require 'rexml/document'
|
8
|
-
include REXML
|
9
5
|
|
10
6
|
class Cmdr
|
11
7
|
|
12
|
-
def initialize(
|
13
|
-
|
14
|
-
opt[:public].merge!({
|
15
|
-
user:
|
16
|
-
{'-1' =>
|
17
|
-
{
|
18
|
-
history:
|
19
|
-
{list: [], index: []}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
})
|
23
|
-
|
24
|
-
@v = opt[:public]
|
25
|
-
@@app = app_mgr
|
8
|
+
def initialize()
|
26
9
|
|
27
|
-
|
28
|
-
|
10
|
+
@linebuffer = ''
|
11
|
+
@history = []
|
12
|
+
@out = []
|
29
13
|
|
30
|
-
|
31
|
-
def run_cmd(raw_command, user_id='-1', bottom_up_display=true)
|
14
|
+
end
|
32
15
|
|
33
|
-
|
16
|
+
def input(c, enter: "\r", backspace: "\u007F", arrowup: :arrow_up)
|
34
17
|
|
35
|
-
|
18
|
+
key = c
|
36
19
|
|
20
|
+
reveal(c)
|
37
21
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@user_id = user_id unless user_id == '-1'
|
58
|
-
doc = Document.new eval(code)
|
59
|
-
|
60
|
-
node = XPath.first(doc.root, 'summary/javascript')
|
61
|
-
job_with_js = ''
|
22
|
+
@out << case key
|
23
|
+
when enter
|
24
|
+
|
25
|
+
command = @linebuffer
|
26
|
+
|
27
|
+
@history << command
|
28
|
+
|
29
|
+
if @linebuffer.length < 1 then
|
30
|
+
return clear_cli()
|
31
|
+
end
|
32
|
+
|
33
|
+
result = yield(@linebuffer)
|
34
|
+
|
35
|
+
if result then
|
36
|
+
display_output("\n" + result)
|
37
|
+
else
|
38
|
+
display_output 'command not found >> ' + @linebuffer.inspect
|
39
|
+
end
|
62
40
|
|
63
|
-
|
64
|
-
|
65
|
-
node.parent.delete node
|
66
|
-
end
|
41
|
+
@linebuffer = ''
|
42
|
+
clear_cli()
|
67
43
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
else
|
77
|
-
item_details = nodes.map do |x|
|
78
|
-
x.cdatas.length > 0 ? x.cdatas.join.strip : x.text.to_s.strip
|
79
|
-
end
|
80
|
-
end
|
81
|
-
"<ul><li>%s</li></ul>" % item_details.join("</li><li>")
|
82
|
-
end
|
83
|
-
out = "<ul><li>%s</li></ul>" % r.join("</li><li>")
|
44
|
+
when backspace
|
45
|
+
@linebuffer.chop!
|
46
|
+
cli_update()
|
47
|
+
when arrowup
|
48
|
+
old_command = @history.last
|
49
|
+
@linebuffer = old_command
|
50
|
+
cli_update old_command
|
84
51
|
else
|
85
|
-
text1 = XPath.first(doc.root, 'summary/title/text() | summary/to_s/text()')
|
86
|
-
out = REXML::Text::unnormalize(text1.to_s).gsub(/"/,'"')
|
87
|
-
end
|
88
52
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
xml = Builder::XmlMarkup.new( :target => buffer='', :indent => 2 )
|
94
|
-
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
95
|
-
xml.result do
|
96
|
-
xml.summary do
|
97
|
-
xml.status 'success'
|
98
|
-
xml.script {xml.cdata!(javascript.join("\n"))}
|
99
|
-
xml.output r.to_s
|
53
|
+
if key.length < 2 then
|
54
|
+
|
55
|
+
@linebuffer << key
|
56
|
+
key
|
100
57
|
end
|
101
|
-
|
58
|
+
|
102
59
|
end
|
103
60
|
|
104
|
-
|
61
|
+
end
|
105
62
|
|
63
|
+
# display the cli banner upon initialisation
|
64
|
+
#
|
65
|
+
def cli_banner()
|
66
|
+
print "> "
|
106
67
|
end
|
107
68
|
|
108
69
|
protected
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
oli = document.createElement('li');
|
115
|
-
|
116
|
-
oli.innerHTML = \"#{out.gsub(/\r|\n/,"").gsub(/"/,'"')}\";
|
117
|
-
ocontent.insertBefore(oli, ocontent.firstChild);
|
118
|
-
|
119
|
-
olist.scrollTop = olist.scrollHeight;
|
120
|
-
|
121
|
-
ocommandInput = document.getElementById('user_input');
|
122
|
-
ocommandInput.value = '';
|
123
|
-
"
|
70
|
+
|
71
|
+
# display the current input
|
72
|
+
#
|
73
|
+
def cli_update(s='')
|
74
|
+
print s
|
124
75
|
end
|
125
76
|
|
126
|
-
|
127
|
-
"
|
128
|
-
ocontent = document.getElementById('content');
|
129
|
-
oli = document.createElement('li');
|
130
|
-
|
131
|
-
oli.innerHTML = \"#{out.gsub(/\r|\n/,"").gsub(/"/,'"')}\";
|
132
|
-
ocontent.appendChild(oli);
|
133
|
-
olist.scrollTop = olist.scrollHeight;
|
77
|
+
alias clear_cli cli_update
|
134
78
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
def run_rscript(rsf_url, jobs, arg='')
|
141
|
-
ajobs = jobs.split(/\s/)
|
142
|
-
args = [rsf_url, ajobs, arg].flatten
|
143
|
-
RScript.new().read(args)
|
79
|
+
# display the output
|
80
|
+
#
|
81
|
+
def display_output(s='')
|
82
|
+
print s
|
144
83
|
end
|
145
84
|
|
146
|
-
|
147
|
-
|
148
|
-
|
85
|
+
# display the key pressed
|
86
|
+
#
|
87
|
+
def reveal(c)
|
88
|
+
print c
|
149
89
|
end
|
150
|
-
|
151
|
-
end
|
152
90
|
|
91
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmdr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,55 +10,29 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
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28
|
+
WftNoNlUZBBtcwoR9k4bZBtIIXB2fzlqHGBFS7Gemy76tDZlKYedQVbzvCG8hjs/
|
29
|
+
Gd8+oGgpxMgFDfpZ6MbbtO33u2qppE+fxtWanBJAjBeWPck9a9OS3Wn2kuNBc9+G
|
30
|
+
H+SzfeQ18BKVa3gXhAvTTAe2rIAImWVuU+kx6cqpFUwMlT89IxEh95yfjD54dooC
|
31
|
+
aQuuxN6Drf3pdfalETmFyPgJ7gU+AcENcNa4wGuZKF786/ki4mt++AhKIiQI+Tbn
|
32
|
+
fduXC3tBaNX+gQ==
|
31
33
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
33
|
-
dependencies:
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: builder
|
36
|
-
requirement: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
type: :runtime
|
42
|
-
prerelease: false
|
43
|
-
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: rscript
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
34
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
35
|
+
dependencies: []
|
62
36
|
description:
|
63
37
|
email: james@r0bertson.co.uk
|
64
38
|
executables: []
|
@@ -76,17 +50,17 @@ require_paths:
|
|
76
50
|
- lib
|
77
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
52
|
requirements:
|
79
|
-
- -
|
53
|
+
- - ">="
|
80
54
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
55
|
+
version: 2.1.2
|
82
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
57
|
requirements:
|
84
|
-
- -
|
58
|
+
- - ">="
|
85
59
|
- !ruby/object:Gem::Version
|
86
60
|
version: '0'
|
87
61
|
requirements: []
|
88
62
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.5.1
|
90
64
|
signing_key:
|
91
65
|
specification_version: 4
|
92
66
|
summary: cmdr
|
metadata.gz.sig
CHANGED
Binary file
|