cmdr 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/cmdr.rb +31 -8
- metadata +2 -2
- 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: b8d936d529e3698ab46c5f4c586278accd5ca9f6
|
4
|
+
data.tar.gz: 92554aa271785174ce0c2413ef00ece23b6f735f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2f15fdc7dc5a2675e7ec82dfcdb67d6c81088c6cd657b5486939ca2ca4385bb282fa9c9ca9edf22eb9d2855704026e6be992802da342f617323bf8a0832fcad
|
7
|
+
data.tar.gz: c0e3a14842e8769e71a42df9ebdb24a40c2cb6db881241e669cf9786047dffae2563add15118d153dc676b2e46e4168d5fd3622e070e91b8ba095ed0030f295f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cmdr.rb
CHANGED
@@ -5,15 +5,17 @@
|
|
5
5
|
|
6
6
|
class Cmdr
|
7
7
|
|
8
|
+
|
8
9
|
def initialize()
|
9
10
|
|
10
11
|
@linebuffer = ''
|
11
12
|
@history = []
|
13
|
+
@history_index = -1
|
12
14
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def input(c, enter: "\r", backspace: "\u007F", arrowup: :arrow_up, arrowdown: :arrow_down)
|
16
|
-
|
18
|
+
|
17
19
|
key = c
|
18
20
|
#return 'var r="e";'
|
19
21
|
reveal(c)
|
@@ -23,7 +25,7 @@ class Cmdr
|
|
23
25
|
|
24
26
|
command = @linebuffer
|
25
27
|
|
26
|
-
@history << command
|
28
|
+
@history << command unless @history.last == command or command.empty?
|
27
29
|
|
28
30
|
if @linebuffer.length < 1 then
|
29
31
|
return clear_cli()
|
@@ -42,16 +44,32 @@ class Cmdr
|
|
42
44
|
|
43
45
|
@linebuffer = ''
|
44
46
|
clear_cli()
|
47
|
+
@history_index = -1
|
45
48
|
|
46
49
|
when backspace
|
47
50
|
@linebuffer.chop!
|
48
51
|
cli_update()
|
49
52
|
when arrowup
|
50
|
-
|
51
|
-
@
|
52
|
-
|
53
|
+
|
54
|
+
return if @history.empty?
|
55
|
+
|
56
|
+
|
57
|
+
clear_cli()
|
58
|
+
command = @history[@history_index]
|
59
|
+
@linebuffer = command
|
60
|
+
@history_index -= 1 if @history_index > -(@history.length)
|
61
|
+
cli_update command
|
62
|
+
|
53
63
|
when arrowdown
|
54
|
-
|
64
|
+
|
65
|
+
return if @history.empty? or @history_index == -1
|
66
|
+
|
67
|
+
clear_cli()
|
68
|
+
@history_index += 1
|
69
|
+
command = @history[@history_index]
|
70
|
+
@linebuffer = command
|
71
|
+
cli_update command
|
72
|
+
|
55
73
|
else
|
56
74
|
|
57
75
|
if key.length < 2 then
|
@@ -71,16 +89,21 @@ class Cmdr
|
|
71
89
|
def cli_banner()
|
72
90
|
print "> "
|
73
91
|
end
|
92
|
+
|
93
|
+
def history()
|
94
|
+
cli_update @history.map.with_index {|x,i| " %s %s" % [i, x]}.join("\n")
|
95
|
+
end
|
74
96
|
|
75
97
|
protected
|
76
98
|
|
77
99
|
# display the current input
|
78
100
|
#
|
79
|
-
def cli_update(s='')
|
101
|
+
def cli_update(s='')
|
80
102
|
print s
|
81
103
|
end
|
82
104
|
|
83
|
-
|
105
|
+
def clear_cli()
|
106
|
+
end
|
84
107
|
|
85
108
|
# display the output
|
86
109
|
#
|
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.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
aQuuxN6Drf3pdfalETmFyPgJ7gU+AcENcNa4wGuZKF786/ki4mt++AhKIiQI+Tbn
|
32
32
|
fduXC3tBaNX+gQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-12-
|
34
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
35
35
|
dependencies: []
|
36
36
|
description:
|
37
37
|
email: james@r0bertson.co.uk
|
metadata.gz.sig
CHANGED
Binary file
|