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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98277c75566374ad544cc93c0421b20dd45213f73f7647bb17a3b4ca674d55c5
4
- data.tar.gz: f242644c7b92f0404c567a9cc59746884663cccad4f110f46912998be549170d
3
+ metadata.gz: 9700d3c97ed89a9c0e5323b3308ddfbe642c1d495141c9fb63ed08d5db876f2f
4
+ data.tar.gz: 3de93385861cd79bcdcb9fa5dc73b0c0d4361e6c37ccee81e614498f753f43bc
5
5
  SHA512:
6
- metadata.gz: 666967b97a23d3284ab5fe31bad702c4ee52ace9de1c02adcfb9b951ed2fcc3525ea3164508f9a6316ab5e2a1ba6e2ed9632973330606fe6cacbf5820f431f8a
7
- data.tar.gz: 2a53cea33d92d939f4f96455eaf8697221fe9d4182d4f9c6d27eec4b3d8e3de4fdb5fe74467ccc5d2304c49ec6b9f8fb3efe9a47f43bec222ac5a04f8306d104
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
- def ask_yes_or_no(question)
31
- loop do
32
- puts question
33
- case gets.chomp
34
- when /\A\s*(yes|yeah|y)\z\s*/i
35
- return true
36
- when /\A\s*(no|nope|n)\z\s*/i
37
- return false
38
- when /\A\s*cancel\s*\z/i
39
- raise 'user canceled yes or no question'
40
- else
41
- puts "Sorry, please answer 'yes', 'no', or 'cancel'"
42
- end#case
43
- end#loop
44
- end#askYesOrNo
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
@@ -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
@@ -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
- # puts <<-HEREDOC.remove_indent
4
- # This is a string
5
- # this part is extra indented
6
- # HEREDOC
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
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.52'
2
+ VERSION = '0.0.53'
3
3
  end
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.52
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: []