appl 1.2 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/intar +12 -21
- data/lib/appl.rb +2 -5
- data/lib/intar.rb +21 -28
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3670591a91a6270557abff4db7e629db25edcced3372b809dfcd045118ecf427
|
4
|
+
data.tar.gz: fecd11d08475460397ec407536bea1002e74cc80e2e35025ef15819c3eb7ebdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da220e1d481946d3f418e724c78b308a8a50bd8173d6b57d41ccf82329a962f6783342ab8d1d46b7ea87524f1378e2cffccf4cda13f577c9f7dc556c70edc802
|
7
|
+
data.tar.gz: c3d50105e3584840e0e5511774aa2a2dd315092add7a597056a7df0f3c31bf309244c66091d5e94c18b21a47820782eb3f0a1a93c3cba4e8a81bb7269b4ca7bc
|
data/bin/intar
CHANGED
@@ -13,7 +13,7 @@ class IntarApp < Application
|
|
13
13
|
NAME = "intar"
|
14
14
|
VERSION = APPL_VERSION
|
15
15
|
SUMMARY = "Interactive Ruby"
|
16
|
-
COPYRIGHT = "(C) 2008-
|
16
|
+
COPYRIGHT = "(C) 2008-2016 Bertram Scharpf <software@bertram-scharpf.de>"
|
17
17
|
LICENSE = "BSD"
|
18
18
|
AUTHOR = "Bertram Scharpf <software@bertram-scharpf.de>"
|
19
19
|
|
@@ -120,27 +120,18 @@ EOT
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
|
124
123
|
def read_cfg
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
rescue Exception
|
137
|
-
$@.pop 2
|
138
|
-
e = $@.shift
|
139
|
-
puts "#{e}: #$! (#{$!.class})"
|
140
|
-
$@.each { |l| puts "\t#{l}" }
|
141
|
-
raise "Error in config file #{c}"
|
142
|
-
end
|
143
|
-
}.value
|
124
|
+
return unless @configfile
|
125
|
+
h = "~" unless @configfile[ File::SEPARATOR]
|
126
|
+
c = File.expand_path @configfile, h
|
127
|
+
return unless File.exists? c
|
128
|
+
load c
|
129
|
+
rescue Exception
|
130
|
+
$@.pop 2
|
131
|
+
e = $@.shift
|
132
|
+
puts "#{e}: #$! (#{$!.class})"
|
133
|
+
$@.each { |l| puts "\t#{l}" }
|
134
|
+
raise "Error in config file #{c}"
|
144
135
|
end
|
145
136
|
|
146
137
|
def nil_if_none var
|
data/lib/appl.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
class Application
|
7
7
|
|
8
|
-
APPL_VERSION = "1.
|
8
|
+
APPL_VERSION = "1.5".freeze
|
9
9
|
|
10
10
|
OPTIONS_ENV = nil
|
11
11
|
|
@@ -91,8 +91,6 @@ This base class does nothing by default.
|
|
91
91
|
$!.to_i rescue 1
|
92
92
|
end
|
93
93
|
|
94
|
-
HASH_ORDER = RUBY_VERSION >= "1.9"
|
95
|
-
|
96
94
|
class <<self
|
97
95
|
|
98
96
|
def run args = nil
|
@@ -209,7 +207,6 @@ This base class does nothing by default.
|
|
209
207
|
all_aliases.each { |k,v|
|
210
208
|
a[ v].push k
|
211
209
|
}
|
212
|
-
a.values.each { |v| v.sort! } unless HASH_ORDER
|
213
210
|
each_option { |opt,desc,arg,dfl,|
|
214
211
|
yield opt, arg, dfl, desc
|
215
212
|
a[ opt].each { |l|
|
@@ -223,7 +220,6 @@ This base class does nothing by default.
|
|
223
220
|
|
224
221
|
def each_option
|
225
222
|
o = all_options
|
226
|
-
o = o.sort_by { |k,v| k.swapcase } unless HASH_ORDER
|
227
223
|
o.each { |opt,(desc,arg,dfl,act)|
|
228
224
|
case dfl
|
229
225
|
when Symbol then dfl = const_get dfl
|
@@ -293,6 +289,7 @@ This base class does nothing by default.
|
|
293
289
|
end
|
294
290
|
end
|
295
291
|
r.concat $*
|
292
|
+
$*.clear
|
296
293
|
r
|
297
294
|
end
|
298
295
|
|
data/lib/intar.rb
CHANGED
@@ -47,7 +47,7 @@ require "supplement/terminal"
|
|
47
47
|
|
48
48
|
|
49
49
|
class Object
|
50
|
-
def
|
50
|
+
def intar_binding
|
51
51
|
binding
|
52
52
|
end
|
53
53
|
end
|
@@ -62,7 +62,7 @@ class Intar
|
|
62
62
|
def initialize filename
|
63
63
|
@filename = filename
|
64
64
|
return unless @filename
|
65
|
-
h = "~" unless @filename
|
65
|
+
h = "~" unless @filename[ File::SEPARATOR]
|
66
66
|
@filename = File.expand_path @filename, h
|
67
67
|
File.exists? @filename and File.open @filename do |h|
|
68
68
|
c = []
|
@@ -238,16 +238,16 @@ class Intar
|
|
238
238
|
autoload :Etc, "etc"
|
239
239
|
autoload :Socket, "socket"
|
240
240
|
|
241
|
-
def cur_prompt
|
241
|
+
def cur_prompt prev
|
242
242
|
t = Time.now
|
243
243
|
self.class.prompt.gsub /%(?:
|
244
|
-
\(([^\)]
|
244
|
+
\(([^\)]+)?\)
|
245
245
|
|
|
246
246
|
([+-]?[0-9]+(?:\.[0-9]+)?)
|
247
247
|
)?(.)/nx do
|
248
248
|
case $3
|
249
249
|
when "s" then @obj.to_s
|
250
|
-
when "i" then $1
|
250
|
+
when "i" then $1 ? (@obj.send $1) : @obj.inspect
|
251
251
|
when "n" then "%#$2d" % @n
|
252
252
|
when "t" then t.strftime $1||"%X"
|
253
253
|
when "u" then Etc.getpwuid.name
|
@@ -255,7 +255,7 @@ class Intar
|
|
255
255
|
when "w" then cwd_short
|
256
256
|
when "W" then File.basename cwd_short
|
257
257
|
when "c" then (colour *($1 || $2 || "").split.map { |x| x.to_i }).to_s
|
258
|
-
when ">" then Process.uid == 0 ? "#" : ">"
|
258
|
+
when ">" then prev ? "." : Process.uid == 0 ? "#" : ">"
|
259
259
|
when "%" then $3
|
260
260
|
else $&
|
261
261
|
end
|
@@ -284,29 +284,23 @@ class Intar
|
|
284
284
|
def readline
|
285
285
|
r, @previous = @previous, nil
|
286
286
|
r or @n += 1
|
287
|
-
cp = cur_prompt
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
else
|
300
|
-
return if l.nil?
|
301
|
-
next unless l =~ /\S/
|
302
|
-
r = l
|
303
|
-
break unless l =~ /\\+\z/ and $&.length % 2 != 0
|
304
|
-
end
|
287
|
+
cp = cur_prompt r
|
288
|
+
begin
|
289
|
+
l = Readline.readline cp
|
290
|
+
rescue Interrupt
|
291
|
+
puts "^C -- #{$!.inspect}"
|
292
|
+
retry
|
293
|
+
end
|
294
|
+
return if l.nil?
|
295
|
+
if r then
|
296
|
+
r << $/ << l
|
297
|
+
else
|
298
|
+
r = l
|
305
299
|
end
|
300
|
+
self.class.hist_add l
|
306
301
|
cp.strip!
|
307
302
|
cp.gsub! /\e\[[0-9]*(;[0-9]*)*m/, ""
|
308
303
|
@file = "#{self.class}/#{cp}"
|
309
|
-
self.class.hist_add r
|
310
304
|
r
|
311
305
|
end
|
312
306
|
|
@@ -354,10 +348,10 @@ class Intar
|
|
354
348
|
class CmdFailed < Exception ; end
|
355
349
|
|
356
350
|
def run *precmds
|
357
|
-
bind = @obj.
|
351
|
+
bind = @obj.intar_binding
|
358
352
|
precmds.each { |l| eval l, bind }
|
359
353
|
oldset = eval OLDSET, bind
|
360
|
-
@cl = eval "caller.length", bind
|
354
|
+
@cl = (eval "caller.length", bind) + 2 # 2 = eval + run()
|
361
355
|
while l = readline do
|
362
356
|
re_sh_pref = /\A#{Regexp.quote self.class.sh_pref}/
|
363
357
|
re_pi_suff = /#{Regexp.quote self.class.pi_suff}\z/
|
@@ -432,7 +426,6 @@ class Intar
|
|
432
426
|
bt = $@.dup
|
433
427
|
if bt.length > @cl then
|
434
428
|
bt.pop @cl
|
435
|
-
bt.push bt.pop[ /(.*:\d+):.*/, 1]
|
436
429
|
end
|
437
430
|
puts bt
|
438
431
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: supplement
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2'
|
11
|
+
date: 2019-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: |
|
28
14
|
A base class for command line applications doing options parsing
|
29
15
|
and generating exit codes.
|
@@ -39,7 +25,7 @@ files:
|
|
39
25
|
- lib/intar.rb
|
40
26
|
homepage: http://www.bertram-scharpf.de/software/appl
|
41
27
|
licenses:
|
42
|
-
- BSD
|
28
|
+
- BSD-2-Clause
|
43
29
|
metadata: {}
|
44
30
|
post_install_message:
|
45
31
|
rdoc_options: []
|
@@ -58,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
59
45
|
- Just Ruby
|
60
46
|
rubyforge_project: NONE
|
61
|
-
rubygems_version: 2.
|
47
|
+
rubygems_version: 2.7.8
|
62
48
|
signing_key:
|
63
49
|
specification_version: 4
|
64
50
|
summary: Easy option parsing
|