atk_toolbox 0.0.52 → 0.0.53
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 +38 -26
- data/lib/atk/extra_file_utils.rb +1 -11
- data/lib/atk/remove_indent.rb +6 -4
- data/lib/atk_toolbox/version.rb +1 -1
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9700d3c97ed89a9c0e5323b3308ddfbe642c1d495141c9fb63ed08d5db876f2f
|
4
|
+
data.tar.gz: 3de93385861cd79bcdcb9fa5dc73b0c0d4361e6c37ccee81e614498f753f43bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9ccbd9997278bf730b109922b593cc702d084f0256fa62241611349ef307a25ca2b764ae1a9c3129a489a5fd4b51e902ac9428326abfcd56e2cb4a9be430bc3
|
7
|
+
data.tar.gz: 34a1c47b978f83e3d78607a966af40785c28fe923d6eb88d418defff523d67fab3ebc34770307772ed237057d0ed3ce4f480ada50b2766f410e51cd5b250513e
|
data/lib/atk/cmd.rb
CHANGED
@@ -1,14 +1,4 @@
|
|
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
|
1
|
+
require "tty-prompt"
|
12
2
|
|
13
3
|
# TODO: switch to using https://github.com/piotrmurach/tty-command#2-interface
|
14
4
|
|
@@ -27,19 +17,41 @@ end
|
|
27
17
|
# Q&A Functions
|
28
18
|
#
|
29
19
|
# TODO: replace these with https://github.com/piotrmurach/tty-prompt
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
20
|
+
# TODO: look into https://piotrmurach.github.io/tty/ to animate the terminal
|
21
|
+
# TODO: look at https://github.com/pazdera/catpix to add an ATK logo in the terminal
|
22
|
+
class TTY::Prompt
|
23
|
+
attr_accessor :verbose
|
24
|
+
def _save_args
|
25
|
+
if @args == nil
|
26
|
+
@args = []
|
27
|
+
for each in ARGV
|
28
|
+
@args << each
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def args
|
34
|
+
self._save_args()
|
35
|
+
return @args
|
36
|
+
end
|
37
|
+
|
38
|
+
def stdin
|
39
|
+
# save arguments before clearing them
|
40
|
+
self._save_args()
|
41
|
+
# must clear arguments in order to get stdin
|
42
|
+
ARGV.clear
|
43
|
+
# check if there is a stdin
|
44
|
+
if !(STDIN.tty?)
|
45
|
+
@stdin = $stdin.read
|
46
|
+
end
|
47
|
+
return @stdin
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Console = TTY::Prompt.new
|
45
52
|
|
53
|
+
def log(*args)
|
54
|
+
if Console.verbose
|
55
|
+
puts(*args)
|
56
|
+
end
|
57
|
+
end
|
data/lib/atk/extra_file_utils.rb
CHANGED
@@ -3,6 +3,7 @@ require 'fileutils'
|
|
3
3
|
require 'pathname'
|
4
4
|
require 'open-uri'
|
5
5
|
require_relative './os'
|
6
|
+
require_relative './remove_indent'
|
6
7
|
|
7
8
|
if OS.is?("unix")
|
8
9
|
HOME = Etc.getpwuid.dir
|
@@ -20,17 +21,6 @@ class String
|
|
20
21
|
File.join(self, next_string)
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|
24
|
-
# this is for having docstrings that get their indent removed
|
25
|
-
# this is used frequently for multi-line strings and error messages
|
26
|
-
# example usage
|
27
|
-
# puts <<-HEREDOC.remove_indent
|
28
|
-
# This command does such and such.
|
29
|
-
# this part is extra indented
|
30
|
-
# HEREDOC
|
31
|
-
def remove_indent
|
32
|
-
gsub(/^[ \t]{#{self.match(/^[ \t]*/)[0].length}}/, '')
|
33
|
-
end
|
34
24
|
end
|
35
25
|
|
36
26
|
class FileSys
|
data/lib/atk/remove_indent.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
class String
|
2
|
+
# this is for having docstrings that get their indent removed
|
3
|
+
# this is used frequently for multi-line strings and error messages
|
2
4
|
# example usage
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
# puts <<-HEREDOC.remove_indent
|
6
|
+
# This command does such and such.
|
7
|
+
# this part is extra indented
|
8
|
+
# HEREDOC
|
7
9
|
def remove_indent
|
8
10
|
gsub(/^[ \t]{#{self.match(/^[ \t]*/)[0].length}}/, '')
|
9
11
|
end
|
data/lib/atk_toolbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atk_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Hykin
|
@@ -50,6 +50,26 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.5.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: tty-prompt
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.19.0
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.19.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.19.0
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.19.0
|
53
73
|
description: ''
|
54
74
|
email: jeff.hykin@gmail.com
|
55
75
|
executables: []
|