rbcli 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33e6d713e741e80cdf48db2fbb70f3792e45df71b763d6fe80a8af946d4b2289
4
- data.tar.gz: ba6204362da692fa141bf719cec73541c7a638a71236a0168a799898ed193334
3
+ metadata.gz: a6b4a98c7a6e1974987798099020dbb037a5966f1b463832a23caed9dcf3e3f6
4
+ data.tar.gz: c4dba14eeb1fc10a17022b0082b3f6a8d3679de8a4f9d292d34c4d35547ac7d9
5
5
  SHA512:
6
- metadata.gz: 729410aa90d602fcd35632d2d05e5243357af944e0e0363d18fde139fc9b9713e8d94f52caad1ab270f5e709873dccebf39fb50da2519043da60748e59a5552b
7
- data.tar.gz: 3a4bc66baf02efefa8f11f806281318d23ef28c860fff11cb7ee5d03c0a9bbb50b24b938e5923cd821e2c8c438784f18cf27a87e8b7cfc4d6b1111d5d7681545
6
+ metadata.gz: 62db4643f55cd2c8044441ca209c1ee9d1e8b6377b0c7d09e5bf6015328b0b6291fb8b57f974c2c584faa838b7325f508ddf81394f90cc0d5cc49d8a32183c32
7
+ data.tar.gz: d2bd43820d8f6ab88424f96f0fb5767312d9267cd06782ff060400c41759e801f7d36828919e084b16650b65749519ac581145850ee7381f007e2e2e3103d084
data/CHANGELOG.md CHANGED
@@ -1,10 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.8 (Nov 7, 2018)
4
+
5
+ ### Features
6
+
7
+ * Added a standardized message I/O system
8
+
9
+ ### Improvements
10
+
11
+ * Enabled the safe usage of anchors in YAML config files
12
+ * Improved the method of determining the script name to be more portable across OS'es
13
+
14
+ ### Bugfixes
15
+
16
+ * Fixed an error which caused RBCli to crash when using `local_state`
17
+ * Fixed a bug which caused the `rbcli init` command to occassionally fail for mini and micro projects
18
+
19
+ ### Changes
20
+
21
+ * Changed the `rbcli init` helptext to match the order of complexity of projects (standard -> mini -> micro)
22
+
3
23
  ## 0.2.7 (Oct 17, 2018)
4
24
 
5
25
  ### Improvements
26
+
6
27
  * Added a dev mode for scripts that allows using a local RBCli copy instead of requiring the gem to be installed
7
- * Added a
8
28
 
9
29
  ### Bugfixes
10
30
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbcli (0.2.7)
4
+ rbcli (0.2.8)
5
5
  aws-sdk-dynamodb (~> 1.6)
6
6
  colorize (~> 0.8)
7
7
  deep_merge (~> 1.2)
@@ -18,8 +18,8 @@ GEM
18
18
  addressable (2.5.2)
19
19
  public_suffix (>= 2.0.2, < 4.0)
20
20
  aws-eventstream (1.0.1)
21
- aws-partitions (1.105.0)
22
- aws-sdk-core (3.31.0)
21
+ aws-partitions (1.106.0)
22
+ aws-sdk-core (3.32.0)
23
23
  aws-eventstream (~> 1.0)
24
24
  aws-partitions (~> 1.0)
25
25
  aws-sigv4 (~> 1.0)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  RBCli is currently in Alpha stages of development. All releases can be considered stable, though breaking changes may be made between versions.
4
4
 
5
- Latest Release: v0.2.7 (Oct 17, 2018) -- See the [changelog][changelog] for complete details.
5
+ Latest Release: v0.2.8 (Nov 7, 2018) -- See the [changelog][changelog] for complete details.
6
6
 
7
7
  [You can find the Official Documentation for RBCli Here.][documentation_home]
8
8
 
data/exe/rbcli CHANGED
@@ -80,7 +80,7 @@ Micro: A single-file, minimal RBCli project. Similar to a mini project, but o
80
80
  EOF
81
81
 
82
82
  parameter :name, 'Name of project to generate', type: :string, default: File.basename(Dir.pwd), required: true, prompt: 'Enter a name'
83
- parameter :type, 'Specify project type', type: :string, permitted: %w(standard micro mini), default: 'standard'
83
+ parameter :type, 'Specify project type', type: :string, permitted: %w(standard mini micro), default: 'standard'
84
84
  parameter :description, 'A description of the project', type: :string, default: 'TODO: Description goes here'
85
85
 
86
86
  action do |params, args, global_opts, config|
@@ -112,7 +112,7 @@ EOF
112
112
  if success
113
113
  puts "\nInitialization Complete!\n"
114
114
  else
115
- puts "\nAn RBCli Project already exists in the current directory tree at: #{proj.exists?}. Please delete the project or run this command from a different directory.\n"
115
+ puts "\nAn RBCli Project already exists in the current or specified directory tree. Please delete the project or run this command from a different directory.\n"
116
116
  end
117
117
  end
118
118
  end
@@ -79,12 +79,12 @@ module RBCliTool
79
79
 
80
80
  def create_mini force = false
81
81
  return false if project_exists? and not force
82
- RBCliTool.cp_file @minipath, @dest, @template_vars
82
+ RBCliTool.cp_file @minipath, "#{@dest}/#{@template_vars[:cmdname]}", @template_vars
83
83
  end
84
84
 
85
85
  def create_micro force = false
86
86
  return false if project_exists? and not force
87
- RBCliTool.cp_file @micropath, @dest, @template_vars
87
+ RBCliTool.cp_file @micropath, "#{@dest}/#{@template_vars[:cmdname]}", @template_vars
88
88
  end
89
89
 
90
90
  def exists?
@@ -36,6 +36,7 @@ module RBCliTool
36
36
  dest = "#{dest}#{src.split('/')[-1]}" if dest.end_with? '/'
37
37
  if File.exists? dest
38
38
  puts "File #{dest} already exists. Please delete it and try again."
39
+ false
39
40
  else
40
41
  print "Generating file " + dest + " ... "
41
42
 
@@ -48,6 +49,7 @@ module RBCliTool
48
49
 
49
50
  FileUtils.rm_f "#{File.dirname(dest)}/.keep" if File.exists? "#{File.dirname(dest)}/.keep"
50
51
  puts "Done!"
52
+ true
51
53
  end
52
54
  end
53
55
 
data/lib/rbcli.rb CHANGED
@@ -37,6 +37,7 @@ require 'rbcli/version'
37
37
  # UTILS
38
38
  require 'rbcli/util/hash_deep_symbolize'
39
39
  require 'rbcli/util/deprecation_warning'
40
+ require 'rbcli/util/msg'
40
41
  #require 'rbcli/util/string_colorize' # We are using the colorize gem instead. The code is kept here for reference.
41
42
  # END UTILS
42
43
 
@@ -111,13 +111,13 @@ module Rbcli::Config
111
111
  @config_text << "\n\n" << text if text
112
112
 
113
113
  @config_defaults ||= {}
114
- @config_defaults.deep_merge! YAML::load(@config_text).deep_symbolize!
114
+ @config_defaults.deep_merge! YAML.safe_load(@config_text, [], [], true).deep_symbolize!
115
115
  @loaded = false
116
116
  end
117
117
 
118
118
  def self.load
119
119
  if (! @config_file.nil?) and File.exists? @config_file
120
- @config = YAML::load(File.read(@config_file)).deep_symbolize!
120
+ @config = YAML.safe_load(File.read(@config_file), [], [], true).deep_symbolize!
121
121
  @config.deep_merge! @config_defaults if @merge_defaults
122
122
  elsif @userfile_required
123
123
  puts "User's config file not found at #{@config_file}. Please run this tool with the `--generate-config` option to generate it."
@@ -0,0 +1,55 @@
1
+ module Rbcli::Msg
2
+ def self.print message, log: false, color: nil
3
+ Rbcli::log.info {message} if log
4
+ STDOUT.print message
5
+ end
6
+
7
+ def self.puts message, log: false, color: nil
8
+ Rbcli::log.info {message} if log
9
+ message = message.colorize(color) if Rbcli::config[:colorize_output]
10
+ STDOUT.puts message
11
+ end
12
+
13
+ def self.err message, log: false, color: :yellow
14
+ Rbcli::log.warn {message} if log
15
+ message = message.colorize(color) if Rbcli::config[:colorize_output]
16
+ STDERR.puts message
17
+ end
18
+
19
+ def self.fatal message, log: true, color: :red, exitcode: 1
20
+ Rbcli::log.fatal {"Exited with the message: " + message} if log
21
+ message = "Error: #{message}"
22
+ message = message.colorize(color) if Rbcli::config[:colorize_output]
23
+ STDERR.puts message
24
+ exit exitcode
25
+ end
26
+
27
+ @triggernests = 0
28
+
29
+ def self.triggered msg, msg_success, msg_fail = nil, fatality_msg = nil, log: false, success_color: :green, fail_color: :red, newline: false, &block
30
+ @triggernests.times {msg = ' ' + msg}
31
+ @triggernests += 1
32
+
33
+ Rbcli::Msg.send ((newline) ? :puts : :print), msg
34
+ result = yield
35
+ tmsg = (result or msg_fail.nil?) ? msg_success : msg_fail
36
+ tcol = (result or msg_fail.nil?) ? success_color : fail_color
37
+ Rbcli::Msg.puts tmsg, log: log, color: tcol
38
+ Rbcli::Msg.fatal fatality_msg, log: log if fatality_msg
39
+
40
+ @triggernests -= 1
41
+ end
42
+
43
+ def self.yesno question, default_to_yes: false
44
+ yes_display = (default_to_yes) ? 'Y' : 'y'
45
+ no_display = (default_to_yes) ? 'n' : 'N'
46
+ Rbcli::Msg.print "#{question} (#{yes_display}/#{no_display}): ", log: false
47
+ if default_to_yes
48
+ answer = !gets.chomp.casecmp('n').zero?
49
+ else
50
+ answer = gets.chomp.casecmp('y').zero?
51
+ end
52
+ Rbcli::log.info {"Question: #{question}. Answer: #{answer}"}
53
+ answer
54
+ end
55
+ end
data/lib/rbcli/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
  ##################################################################################
20
20
 
21
21
  module Rbcli
22
- VERSION = '0.2.7'
22
+ VERSION = '0.2.8'
23
23
  end
@@ -14,7 +14,7 @@ require (ENV['RBCLI_ENV'] == 'development') ? ENV['RBCLI_DEVPATH'] || 'rbcli' :
14
14
  #########################
15
15
  Rbcli::Configurate.me do
16
16
  ## Script Name -- (Required) -- This line identifies the tool's executable on the command line.
17
- scriptname __FILE__.split('/')[-1]
17
+ scriptname File.basename(__FILE__)
18
18
 
19
19
  ## Version Number -- (Required)
20
20
  version '0.1.0'
@@ -85,7 +85,7 @@ Rbcli::Configurate.storage do
85
85
  # Local State Storage
86
86
  ###
87
87
 
88
- ## Local State -- (Optional) -- Creates a hash that is automatically saved to a file locally for state persistance. It is accessible to all commands at Rbcli.localstate[:yourkeyhere]
88
+ ## Local State -- (Optional) -- Creates a hash that is automatically saved to a file locally for state persistance. It is accessible to all commands at Rbcli.local_state[:yourkeyhere]
89
89
  #local_state '/var/mytool/localstate', force_creation: true, halt_on_error: true
90
90
 
91
91
 
@@ -28,7 +28,7 @@ Rbcli::Configurate.me do
28
28
  ## Script Name -- (Required) -- This line identifies the tool's executable on the command line.
29
29
  # To change it, rename this file to the command you want and this will pick up that name automatically.
30
30
  # You can change it manually if needed, but this should work for most cases.
31
- scriptname __FILE__.split('/')[-1]
31
+ scriptname File.basename(__FILE__)
32
32
 
33
33
  ## Version Number -- (Required)
34
34
  version '0.1.0'
@@ -173,13 +173,14 @@ end
173
173
  ###############################
174
174
  Rbcli::Configurate.storage do
175
175
  ###
176
- # Local State Storage
176
+ # Local State Storage -- (Optional)
177
177
  ###
178
178
  # Local state storage creates a hash that is automatically saved to a file locally for state persistance.
179
- # It is accessible to all commands at: Rbcli.localstate[:yourkeyhere]
179
+ # It is accessible to all commands at: Rbcli.local_state[:yourkeyhere]
180
180
  #
181
181
  # Note that every update to the top level of this hash will trigger a save, and updating nested hashes will not.
182
- # If you need to update nested hashes, you can trigger a save manually by calling `Rbcli.localstate.commit`.
182
+ # If you need to update nested hashes, you can trigger a save manually by calling `Rbcli.local_state.commit`.
183
+ # It is accessible to all commands at: Rbcli.local_state[:yourkeyhere]
183
184
  # Please see the documentation for full usage details.
184
185
  ###
185
186
 
@@ -9,11 +9,11 @@ Rbcli::Configurate.storage do
9
9
  # Local State Storage -- (Optional)
10
10
  ###
11
11
  # Local state storage creates a hash that is automatically saved to a file locally for state persistance.
12
- # It is accessible to all commands at: Rbcli.localstate[:yourkeyhere]
12
+ # It is accessible to all commands at: Rbcli.local_state[:yourkeyhere]
13
13
  #
14
14
  # Note that every update to the top level of this hash will trigger a save, and updating nested hashes will not.
15
- # If you need to update nested hashes, you can trigger a save manually by calling `Rbcli.localstate.commit`.
16
- # It is accessible to all commands at: Rbcli.localstate[:yourkeyhere]
15
+ # If you need to update nested hashes, you can trigger a save manually by calling `Rbcli.local_state.commit`.
16
+ # It is accessible to all commands at: Rbcli.local_state[:yourkeyhere]
17
17
  # Please see the documentation for full usage details.
18
18
  ###
19
19
 
@@ -31,7 +31,7 @@ Rbcli::Configurate.me do
31
31
  ## Script Name -- (Required) -- This line identifies the tool's executable on the command line.
32
32
  # To change it, rename this file to the command you want and this will pick up that name automatically.
33
33
  # You can change it manually if needed, but this should work for most cases.
34
- scriptname __FILE__.split('/')[-1]
34
+ scriptname File.basename(__FILE__)
35
35
 
36
36
  ## Version Number -- (Required)
37
37
  # Here we reference the same constant that we set for our Gem. If not using Rubygems you can change this to
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Khoury
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -309,6 +309,7 @@ files:
309
309
  - lib/rbcli/state_storage/remotestate_dynamodb.rb
310
310
  - lib/rbcli/util/deprecation_warning.rb
311
311
  - lib/rbcli/util/hash_deep_symbolize.rb
312
+ - lib/rbcli/util/msg.rb
312
313
  - lib/rbcli/util/string_colorize.rb
313
314
  - lib/rbcli/util/trollop.rb
314
315
  - lib/rbcli/version.rb