rbcli 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +92 -6
- data/examples/myscript.sh +23 -0
- data/examples/mytool +8 -3
- data/exe/rbcli +31 -8
- data/lib/rbcli/autoupdate/autoupdate.rb +1 -1
- data/lib/rbcli/autoupdate/gem_updater.rb +6 -2
- data/lib/rbcli/autoupdate/github_updater.rb +6 -1
- data/lib/rbcli/{util → configuration}/config.rb +0 -0
- data/lib/rbcli/{configurate.rb → configuration/configurate.rb} +0 -0
- data/lib/rbcli/engine/command.rb +3 -1
- data/lib/rbcli/{util → logging}/logging.rb +0 -0
- data/lib/rbcli/scriptwrapping/scriptwrapper.rb +45 -0
- data/lib/rbcli/version.rb +1 -1
- data/lib/rbcli.rb +26 -2
- metadata +7 -6
- data/lib/rbcli/util.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ab8b75c47014a1d8fc4ebfb019fd510d6878446c0b5e21b534331518779c69
|
4
|
+
data.tar.gz: 76a749c4eedd63b9372abfb5cf742c418e440bf52c07cfb80e14e4890e19dad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 841009711e6ea7507da51246fa3f116c767cee17229775dfb4524e649ed766f20c20069728d426d675d26bdbea9338f0e1a26873fc5120ba63473607815440dd
|
7
|
+
data.tar.gz: edeb6d1302757421d2db44b44c38e07765920a67cd1230c45689541b7a4d29b4b511fd3e3b7d2f08b8abd36b17bbb30c639f71501bfbd5248518b5e4d70cc253
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbcli (0.1.
|
4
|
+
rbcli (0.1.7)
|
5
5
|
aws-sdk-dynamodb (~> 1.6)
|
6
6
|
colorize (~> 0.8)
|
7
7
|
deep_merge (~> 1.2)
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
addressable (2.5.2)
|
16
16
|
public_suffix (>= 2.0.2, < 4.0)
|
17
17
|
aws-eventstream (1.0.0)
|
18
|
-
aws-partitions (1.
|
18
|
+
aws-partitions (1.91.0)
|
19
19
|
aws-sdk-core (3.21.2)
|
20
20
|
aws-eventstream (~> 1.0)
|
21
21
|
aws-partitions (~> 1.0)
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
RBCli is currently in Alpha stages of development. All releases can be considered stable, though breaking changes may be made between versions.
|
2
|
+
|
1
3
|
# RBCli
|
2
4
|
|
3
5
|
RBCli is a framework to quickly develop advanced command-line tools in Ruby. It has been written from the ground up with the needs of the modern technologist in mind, designed to make advanced CLI tool development as painless as possible.
|
@@ -22,10 +24,14 @@ Some of its key features include:
|
|
22
24
|
|
23
25
|
* __Automatic Update Notifications__: Just provide the gem name or git repo, and RBCli will take care of notifying users!
|
24
26
|
|
27
|
+
* __External Script Wrapping__: High-level wrapping for Bash scripts, or any other applcication you'd like to wrap into a command.
|
28
|
+
|
29
|
+
|
25
30
|
## Installation
|
26
31
|
|
27
32
|
RBCli is available on rubygems.org. You can add it to your application's `Gemrile` or `gemspec`, or install it manually via `gem install rbcli`.
|
28
33
|
|
34
|
+
|
29
35
|
## The Basics
|
30
36
|
|
31
37
|
RBCli enforces a general command-line structure:
|
@@ -53,6 +59,7 @@ mytool show -l
|
|
53
59
|
|
54
60
|
Note that all options and parameters will have both a short and long version of the parameter available for use.
|
55
61
|
|
62
|
+
|
56
63
|
## Getting Started
|
57
64
|
|
58
65
|
Creating a new skeleton command is as easy as running `rbcli init <filename>`. It will have these key items:
|
@@ -62,7 +69,6 @@ Creating a new skeleton command is as easy as running `rbcli init <filename>`. I
|
|
62
69
|
* A command declaration
|
63
70
|
* The parse command
|
64
71
|
|
65
|
-
|
66
72
|
### Configuration
|
67
73
|
|
68
74
|
```ruby
|
@@ -119,7 +125,6 @@ If you want to declare more than one option, you can call it multiple times. The
|
|
119
125
|
|
120
126
|
Once parsed, options will be placed in a hash where they can be accessed via their names as shown above. You can see this demonstrated in the `default_action`, `pre_hook`, and `post_hook` blocks.
|
121
127
|
|
122
|
-
|
123
128
|
### Storage Configuration (optional)
|
124
129
|
|
125
130
|
```ruby
|
@@ -144,9 +149,14 @@ class Test < Rbcli::Command
|
|
144
149
|
config_defaults 'defaults.yml' # (Optional, Multiple) Load a YAML file as part of the default config. This can be called multiple times, and the YAML files will be merged. User config is generated from these
|
145
150
|
config_default :myopt2, description: 'Testing this again', value: true # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config
|
146
151
|
|
147
|
-
|
148
|
-
|
149
|
-
|
152
|
+
extern path: 'env | grep "^__PARAMS\|^__ARGS\|^__GLOBAL\|^__CONFIG"', envvars: {MYVAR: 'some_value'} # (Required unless `action` defined) Runs a given application, with optional environment variables, when the user runs the command.
|
153
|
+
extern envvars: {MY_OTHER_VAR: 'another_value'} do |params, args, global_opts, config| # Alternate usage. Supplying a block instead of a path allows us to modify the command based on the arguments and configuration supplied by the user.
|
154
|
+
"echo #{params[:force].to_s}__YESSS!!!"
|
155
|
+
end
|
156
|
+
|
157
|
+
action do |params, args, global_opts, config| # (Required unless `extern` defined) Block to execute if the command is called.
|
158
|
+
Rbcli::log.info { 'These logs can go to STDERR, STDOUT, or a file' } # Example log. Interface is identical to Ruby's logger
|
159
|
+
puts "\nArgs:\n#{args}" # Arguments that came after the command on the CLI (i.e.: `mytool test bar baz` will yield args=['bar', 'baz'])
|
150
160
|
puts "Params:\n#{params}" # Parameters, as described through the option statements above
|
151
161
|
puts "Global opts:\n#{global_opts}" # Global Parameters, as descirbed in the Configurate section
|
152
162
|
puts "Config:\n#{config}" # Config file values
|
@@ -155,7 +165,6 @@ class Test < Rbcli::Command
|
|
155
165
|
puts "\nDone!!!"
|
156
166
|
end
|
157
167
|
end
|
158
|
-
|
159
168
|
```
|
160
169
|
|
161
170
|
### Parse Command
|
@@ -177,6 +186,7 @@ RBCli takes actions in a specific order when `parse` is run.
|
|
177
186
|
ii. Otherwise, show the help
|
178
187
|
b. If a command has been entered, the rest of the CLI is parsed for parameters and lineitems, and the code block for the command is called
|
179
188
|
|
189
|
+
|
180
190
|
## Configuration Files
|
181
191
|
|
182
192
|
RBCli has two chains to manage configuration: the __defaults chain__ and the __user chain__.
|
@@ -209,6 +219,7 @@ Rbcli will determine the correct location to locate the user configuration based
|
|
209
219
|
|
210
220
|
Users can generate configs by running `yourclitool -g`. This will generate a config file at the tool's default location specified in the DSL. A specific location can be used via the `-c` parameter. You can test how this works by running `examples/mytool -c test.yml -g`.
|
211
221
|
|
222
|
+
|
212
223
|
## Logging
|
213
224
|
|
214
225
|
Logging with RBCli is straightforward - it looks at the config file for logging settings, and instantiates a single, globally accessible [Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html)` object. You can access it as such:
|
@@ -233,6 +244,7 @@ logger:
|
|
233
244
|
log_target: stderr # STDOUT, STDERR, or a file path
|
234
245
|
```
|
235
246
|
|
247
|
+
|
236
248
|
## <a name="storage_subsystems"></a>Storage Subsystems
|
237
249
|
|
238
250
|
```ruby
|
@@ -364,6 +376,7 @@ to force the lock and retrieve the latest data. You can force an unlock by calli
|
|
364
376
|
Rbcli.remote_state.disconnect
|
365
377
|
```
|
366
378
|
|
379
|
+
|
367
380
|
## Automatic Update Check
|
368
381
|
|
369
382
|
RBCli can automatically notify users when an update is available. If `force_update` is set (see below), RBCli can halt execution until the user updates their application.
|
@@ -399,20 +412,93 @@ The `gem` parameter should simply state the name of the gem.
|
|
399
412
|
|
400
413
|
Setting `force_update: true` will halt execution if an update is available, forcing the user to update.
|
401
414
|
|
415
|
+
|
416
|
+
## External Script Wrapping
|
417
|
+
|
418
|
+
RBCli has the ability to run an external application as a CLI command, passing CLI parameters and environment variables as desired. It provides two modes -- __direct path__ and __variable path__ -- which work similarly through the `extern` keyword.
|
419
|
+
|
420
|
+
When an external script is defined in a command, an `action` is no longer required.
|
421
|
+
|
422
|
+
To quickly generate a script that shows the environment variables passed to it, you can use RBCli's own tool: `rbcli script`
|
423
|
+
|
424
|
+
### Direct Path Mode
|
425
|
+
|
426
|
+
```ruby
|
427
|
+
class Test < Rbcli::Command # Declare a new command by subclassing Rbcli::Command
|
428
|
+
description 'This is a short description.' # (Required) Short description for the global help
|
429
|
+
usage 'This is some really long usage text description!' # (Required) Long description for the command-specific help
|
430
|
+
parameter :force, 'Force testing', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times
|
431
|
+
|
432
|
+
extern path: 'env | grep "^__PARAMS\|^__ARGS\|^__GLOBAL\|^__CONFIG\|^MYVAR"', envvars: {MYVAR: 'some_value'} # (Required unless `action` defined) Runs a given application, with optional environment variables, when the user runs the command.
|
433
|
+
end
|
434
|
+
```
|
435
|
+
|
436
|
+
Here, we supply a string to run the command. We can optioanlly provide environment variables which will be available for the script to use.
|
437
|
+
|
438
|
+
RBCli will automatically set several environment variables as well. As you may have guessed by the example above, they are prefixed with:
|
439
|
+
|
440
|
+
* `__PARAMS`
|
441
|
+
* `__ARGS`
|
442
|
+
* `__GLOBAL`
|
443
|
+
* `__CONFIG`
|
444
|
+
|
445
|
+
These prefixes are applied to their respective properties in RBCli, similar to what you would see when using an `action`.
|
446
|
+
|
447
|
+
The command in the example above will show you a list of variables, which should look something like this:
|
448
|
+
|
449
|
+
```bash
|
450
|
+
__GLOBAL_VERSION=false
|
451
|
+
__GLOBAL_HELP=false
|
452
|
+
__GLOBAL_GENERATE_CONFIG=false
|
453
|
+
__GLOBAL_CONFIG_FILE="/etc/mytool/config.yml"
|
454
|
+
__CONFIG_LOGGER={"log_level":"info","log_target":"stderr"}
|
455
|
+
__CONFIG_MYOPT=true
|
456
|
+
__CONFIG_GITHUB_UPDATE={"access_token":null,"enterprise_hostname":null}
|
457
|
+
__PARAMS_FORCE=false
|
458
|
+
__PARAMS_HELP=false
|
459
|
+
MYVAR=some_value
|
460
|
+
```
|
461
|
+
|
462
|
+
As you can see above, items which have nested values they are passed in as JSON. If you need to parse them, [JQ](https://stedolan.github.io/jq/) is recommended.
|
463
|
+
|
464
|
+
### Variable Path Mode
|
465
|
+
|
466
|
+
Variable Path Mode works the same as Direct Path Mode, only instead of providing a string we provide a block that returns a string. This allows us to generate different commands based on the CLI parameters that the user passed:
|
467
|
+
|
468
|
+
```ruby
|
469
|
+
class Test < Rbcli::Command # Declare a new command by subclassing Rbcli::Command
|
470
|
+
description 'This is a short description.' # (Required) Short description for the global help
|
471
|
+
usage 'This is some really long usage text description!' # (Required) Long description for the command-specific help
|
472
|
+
parameter :force, 'Force testing', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times
|
473
|
+
|
474
|
+
extern envvars: {MY_OTHER_VAR: 'another_value'} do |params, args, global_opts, config| # Alternate usage. Supplying a block instead of a path allows us to modify the command based on the arguments and configuration supplied by the user.
|
475
|
+
if params[:force].to_s
|
476
|
+
"externalapp --test-script foo --ignore-errors"
|
477
|
+
else
|
478
|
+
"externalapp"
|
479
|
+
end
|
480
|
+
end
|
481
|
+
end
|
482
|
+
```
|
483
|
+
|
484
|
+
|
402
485
|
## Development
|
403
486
|
|
404
487
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
405
488
|
|
406
489
|
To install this gem onto your local machine from source, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
407
490
|
|
491
|
+
|
408
492
|
## Contributing
|
409
493
|
|
410
494
|
Bug reports and pull requests are welcome on GitHub at https://github.com/akhoury6/rbcli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
411
495
|
|
496
|
+
|
412
497
|
## License
|
413
498
|
|
414
499
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
415
500
|
|
501
|
+
|
416
502
|
## Code of Conduct
|
417
503
|
|
418
504
|
Everyone interacting in the Rbcli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/akhoury6/rbcli/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
###
|
4
|
+
# This is the RBCli script for the command {{**CMDNAME**}}
|
5
|
+
###
|
6
|
+
#
|
7
|
+
# You can find RBCli's params, args, global_opts, and config through environment
|
8
|
+
# variables. They are passed in the formats:
|
9
|
+
#
|
10
|
+
# __PARAMS_<param_name>
|
11
|
+
# __ARGS_<arg_name>
|
12
|
+
# __GOBAL <global_opt_name>
|
13
|
+
# __CONFIG <config_name>
|
14
|
+
#
|
15
|
+
# If any of the options given had nested values in your RBCli application they
|
16
|
+
# will be passed as JSON. You can parse them using jq ( https://stedolan.github.io/jq/ )
|
17
|
+
#
|
18
|
+
# If you specified any environment variables to be set manually, they will be found unmodified.
|
19
|
+
#
|
20
|
+
###
|
21
|
+
#
|
22
|
+
|
23
|
+
env | grep "^__PARAMS\|^__ARGS\|^__GLOBAL\|^__CONFIG"
|
data/examples/mytool
CHANGED
@@ -69,9 +69,14 @@ class Test < Rbcli::Command
|
|
69
69
|
config_defaults 'defaults.yml' # (Optional, Multiple) Load a YAML file as part of the default config. This can be called multiple times, and the YAML files will be merged. User config is generated from these
|
70
70
|
config_default :myopt2, description: 'Testing this again', value: true # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
extern path: 'env | grep "^__PARAMS\|^__ARGS\|^__GLOBAL\|^__CONFIG"', envvars: {MYVAR: 'some_value'} # (Required unless `action` defined) Runs a given application, with optional environment variables, when the user runs the command.
|
73
|
+
extern envvars: {MY_OTHER_VAR: 'another_value'} do |params, args, global_opts, config| # Alternate usage. Supplying a block instead of a path allows us to modify the command based on the arguments and configuration supplied by the user.
|
74
|
+
"echo #{params[:force].to_s}__YESSS!!!"
|
75
|
+
end
|
76
|
+
|
77
|
+
action do |params, args, global_opts, config| # (Required unless `extern` defined) Block to execute if the command is called.
|
78
|
+
Rbcli::log.info { 'These logs can go to STDERR, STDOUT, or a file' } # Example log. Interface is identical to Ruby's logger
|
79
|
+
puts "\nArgs:\n#{args}" # Arguments that came after the command on the CLI (i.e.: `mytool test bar baz` will yield args=['bar', 'baz'])
|
75
80
|
puts "Params:\n#{params}" # Parameters, as described through the option statements above
|
76
81
|
puts "Global opts:\n#{global_opts}" # Global Parameters, as descirbed in the Configurate section
|
77
82
|
puts "Config:\n#{config}" # Config file values
|
data/exe/rbcli
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rbcli'
|
4
4
|
|
5
|
-
Rbcli::
|
5
|
+
Rbcli::Configurate.me do
|
6
6
|
scriptname __FILE__.split('/')[-1]
|
7
7
|
version Rbcli::VERSION
|
8
8
|
description 'RBCli initialization tool'
|
@@ -16,15 +16,38 @@ class Init < Rbcli::Command
|
|
16
16
|
action do |params, args, global_opts, config|
|
17
17
|
src = "#{File.dirname(__FILE__)}/../examples/mytool"
|
18
18
|
dest = "#{Dir.pwd}/#{params[:filename]}"
|
19
|
-
|
20
|
-
puts "File #{params[:filename]} already exists. Please delete and try again."
|
21
|
-
else
|
22
|
-
puts "Generating file #{params[:filename]}..."
|
23
|
-
FileUtils.cp src, dest
|
24
|
-
puts "Done!"
|
25
|
-
end
|
19
|
+
cp_file src, dest
|
26
20
|
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Script < Rbcli::Command
|
24
|
+
description 'Initialize a skeleton bash script to use as an RBCli command.'
|
25
|
+
usage 'This will generate a new file in the current folder.'
|
26
|
+
parameter :filename, 'Name of file to generate', type: :string, required: true
|
27
27
|
|
28
|
+
action do |params, args, global_opts, config|
|
29
|
+
src = "#{File.dirname(__FILE__)}/../examples/myscript.sh"
|
30
|
+
dest = "#{Dir.pwd}/#{params[:filename]}"
|
31
|
+
cp_file src, dest, template_vars: {'CMDNAME' => params[:filename].chomp('.sh')}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def cp_file src, dest, template_vars: nil
|
36
|
+
if File.exists? dest
|
37
|
+
puts "File #{dest} already exists. Please delete it and try again."
|
38
|
+
elsif template_vars
|
39
|
+
print "Generating file #{dest}..."
|
40
|
+
text = File.read src
|
41
|
+
template_vars.each do |k, v|
|
42
|
+
text.gsub! /{{\*\*#{k}\*\*}}/, v
|
43
|
+
end
|
44
|
+
File.open(dest, 'w') { |file| file.write text }
|
45
|
+
puts "Done!"
|
46
|
+
else
|
47
|
+
print "Generating file #{dest}..."
|
48
|
+
FileUtils.cp src, dest
|
49
|
+
puts "Done!"
|
50
|
+
end
|
28
51
|
end
|
29
52
|
|
30
53
|
Rbcli.parse
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Rbcli::Configurate
|
2
2
|
def self.autoupdate gem: nil, github_repo: nil, access_token: nil, enterprise_hostname: nil, force_update: false
|
3
|
-
raise StandardError.new "Autoupdater can not have both a gem and git target defined. Please pick one." if gem and
|
3
|
+
raise StandardError.new "Autoupdater can not have both a gem and git target defined. Please pick one." if gem and github_repo
|
4
4
|
raise StandardError.new "Only one autoupdater can be defined." if @data[:autoupdater]
|
5
5
|
if gem
|
6
6
|
#Rbcli::Autoupdate::GemUpdater.save_defaults
|
@@ -12,8 +12,12 @@ module Rbcli::Autoupdate
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_latest_version
|
15
|
-
|
16
|
-
|
15
|
+
begin
|
16
|
+
response = Net::HTTP.get(@uri)
|
17
|
+
JSON.parse(response)['version']
|
18
|
+
rescue SocketError => e
|
19
|
+
# Capture connection errors
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def update_message
|
@@ -24,7 +24,12 @@ module Rbcli::Autoupdate
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def get_latest_version
|
27
|
-
|
27
|
+
begin
|
28
|
+
@client.repo(@reponame).rels[:tags].get.data.map{ |t| t[:name] }[0].sub(/^[v]*/,"")
|
29
|
+
rescue Faraday::ConnectionFailed => e
|
30
|
+
# This is to capture connection errors without bothering the user.
|
31
|
+
end
|
32
|
+
|
28
33
|
end
|
29
34
|
|
30
35
|
def update_message
|
File without changes
|
File without changes
|
data/lib/rbcli/engine/command.rb
CHANGED
@@ -63,7 +63,9 @@ class Rbcli::Command
|
|
63
63
|
global_opts = cliopts
|
64
64
|
config = Rbcli::config
|
65
65
|
|
66
|
-
@commands[cmd].
|
66
|
+
raise Exception.new("Command #{cmd} has both an extern and action defined. Usage is limiated to one at a time.") if @commands[cmd].extern and @commands[cmd].action
|
67
|
+
@commands[cmd].extern.execute params, args, global_opts, config unless @commands[cmd].extern.nil?
|
68
|
+
@commands[cmd].action.call params, args, global_opts, config unless @commands[cmd].action.nil?
|
67
69
|
end
|
68
70
|
|
69
71
|
##
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Rbcli::Command
|
2
|
+
def self.extern path: nil, envvars: nil, &block
|
3
|
+
block = nil unless block_given?
|
4
|
+
@extern = Rbcli::Scriptwrapper.new path, envvars, block
|
5
|
+
end
|
6
|
+
|
7
|
+
def extern;
|
8
|
+
@extern ||= nil
|
9
|
+
self.class.instance_variable_get :@extern
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'json'
|
14
|
+
class Rbcli::Scriptwrapper
|
15
|
+
def initialize path, envvars = nil, block = nil
|
16
|
+
@path = path
|
17
|
+
@envvars = envvars
|
18
|
+
@block = block
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute params, args, global_opts, config
|
22
|
+
env_hash = {}
|
23
|
+
{
|
24
|
+
'__PARAMS' => params,
|
25
|
+
'__ARGS' => args,
|
26
|
+
'__GLOBAL' => global_opts,
|
27
|
+
'__CONFIG' => config
|
28
|
+
}.each do |name, hsh|
|
29
|
+
hsh.each do |k, v|
|
30
|
+
env_hash["#{name}_#{k.upcase}"] = v.to_json
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
env_hash.merge!(@envvars.deep_stringify!) unless @envvars.nil?
|
35
|
+
|
36
|
+
if @block
|
37
|
+
path = @block.call params, args, global_opts, config
|
38
|
+
else
|
39
|
+
path = @path
|
40
|
+
end
|
41
|
+
|
42
|
+
system(env_hash, path)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/lib/rbcli/version.rb
CHANGED
data/lib/rbcli.rb
CHANGED
@@ -1,10 +1,29 @@
|
|
1
|
+
###########
|
2
|
+
## RBCLI ##
|
3
|
+
###########
|
4
|
+
#
|
5
|
+
# This file loads the Rbcli systems.
|
6
|
+
#
|
7
|
+
# Utils and Prereqs must be loaded first.
|
8
|
+
#
|
9
|
+
###########
|
10
|
+
|
1
11
|
lib = File.expand_path('../../lib', __FILE__)
|
2
12
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
13
|
|
4
14
|
module Rbcli end # Empty module declaration required to declare submodules freely
|
5
15
|
require "rbcli/version"
|
6
16
|
|
7
|
-
|
17
|
+
# UTILS
|
18
|
+
require 'rbcli/util/hash_deep_symbolize'
|
19
|
+
#require 'rbcli/util/string_colorize' # We are using the colorize gem instead. The code is kept here for reference.
|
20
|
+
# END UTILS
|
21
|
+
|
22
|
+
# BASE PREREQS
|
23
|
+
require 'rbcli/configuration/config'
|
24
|
+
require 'rbcli/logging/logging'
|
25
|
+
# END BASE PREREQS
|
26
|
+
|
8
27
|
|
9
28
|
# STATE TOOLS
|
10
29
|
require "rbcli/stateful_systems/configuratestorage"
|
@@ -17,7 +36,12 @@ require "rbcli/stateful_systems/storagetypes/remotestate_dynamodb"
|
|
17
36
|
require "rbcli/autoupdate/autoupdate"
|
18
37
|
# END AUTOUPDATE
|
19
38
|
|
20
|
-
|
39
|
+
# SCRIPT WRAPPER
|
40
|
+
require "rbcli/scriptwrapping/scriptwrapper"
|
41
|
+
# END SCRIPT WRAPPER
|
21
42
|
|
43
|
+
# CORE
|
44
|
+
require "rbcli/configuration/configurate"
|
22
45
|
require "rbcli/engine/command"
|
23
46
|
require "rbcli/engine/parser"
|
47
|
+
# END CORE
|
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.1.
|
4
|
+
version: 0.1.7
|
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-06-
|
11
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -155,24 +155,25 @@ files:
|
|
155
155
|
- bin/console
|
156
156
|
- bin/setup
|
157
157
|
- examples/defaults.yml
|
158
|
+
- examples/myscript.sh
|
158
159
|
- examples/mytool
|
159
160
|
- exe/rbcli
|
160
161
|
- lib/rbcli.rb
|
161
162
|
- lib/rbcli/autoupdate/autoupdate.rb
|
162
163
|
- lib/rbcli/autoupdate/gem_updater.rb
|
163
164
|
- lib/rbcli/autoupdate/github_updater.rb
|
164
|
-
- lib/rbcli/
|
165
|
+
- lib/rbcli/configuration/config.rb
|
166
|
+
- lib/rbcli/configuration/configurate.rb
|
165
167
|
- lib/rbcli/engine/command.rb
|
166
168
|
- lib/rbcli/engine/parser.rb
|
169
|
+
- lib/rbcli/logging/logging.rb
|
170
|
+
- lib/rbcli/scriptwrapping/scriptwrapper.rb
|
167
171
|
- lib/rbcli/stateful_systems/configuratestorage.rb
|
168
172
|
- lib/rbcli/stateful_systems/state_storage.rb
|
169
173
|
- lib/rbcli/stateful_systems/storagetypes/localstate.rb
|
170
174
|
- lib/rbcli/stateful_systems/storagetypes/remote_state_connectors/dynamodb.rb
|
171
175
|
- lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb
|
172
|
-
- lib/rbcli/util.rb
|
173
|
-
- lib/rbcli/util/config.rb
|
174
176
|
- lib/rbcli/util/hash_deep_symbolize.rb
|
175
|
-
- lib/rbcli/util/logging.rb
|
176
177
|
- lib/rbcli/util/string_colorize.rb
|
177
178
|
- lib/rbcli/util/trollop.rb
|
178
179
|
- lib/rbcli/version.rb
|
data/lib/rbcli/util.rb
DELETED