atk_toolbox 0.0.3 → 0.0.4
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/lib/atk/cmd.rb +37 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d964a5f967172531ef2a23d40319702f0f797d68aa98e8edc74388822c427e1
|
4
|
+
data.tar.gz: 8833017e32e64592a6631507cc28d5f7a94837030ebb5c78c3434f882fd375aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 208563db733b06e4509b198567eee63666e54b002bb858e91a4257e22e147810c11f664dd8c62359d281b6df281811ed7d27326182621bbea803c3a89f444dfc
|
7
|
+
data.tar.gz: 43b86e89ebf073c2046aba914667e5b76ae52c250e530b05ffa6cbfcce24234af8ab6fa8442a9120bad6c45bd33e818b8cdbf5c052fa6530e35d0b25d316be62
|
data/lib/atk/cmd.rb
CHANGED
@@ -1,7 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# extract all the command line input so STDIN can be used
|
3
|
+
#
|
4
|
+
def commandline_args()
|
5
|
+
the_args = []
|
6
|
+
for each in ARGV
|
7
|
+
the_args << each
|
8
|
+
end
|
9
|
+
ARGV.clear
|
10
|
+
return the_args
|
11
|
+
end
|
12
|
+
|
13
|
+
# easy access to the commandline
|
1
14
|
class String
|
2
15
|
# add a - operator to strings that makes it behave like a system() call
|
3
16
|
# but it shows stderr
|
4
17
|
def -@
|
5
|
-
|
18
|
+
Process.wait(Process.spawn(self))
|
19
|
+
return $?
|
6
20
|
end
|
7
|
-
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
#
|
25
|
+
# Q&A Functions
|
26
|
+
#
|
27
|
+
def ask_yes_or_no(question)
|
28
|
+
loop do
|
29
|
+
puts question
|
30
|
+
case gets.chomp
|
31
|
+
when /\A\s*(yes|yeah|y)\z\s*/i
|
32
|
+
return true
|
33
|
+
when /\A\s*(no|nope|n)\z\s*/i
|
34
|
+
return false
|
35
|
+
when /\A\s*cancel\s*\z/i
|
36
|
+
raise 'user canceled yes or no question'
|
37
|
+
else
|
38
|
+
puts "Sorry, please answer 'yes', 'no', or 'cancel'"
|
39
|
+
end#case
|
40
|
+
end#loop
|
41
|
+
end#askYesOrNo
|
42
|
+
|