rbcli 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +12 -12
- data/LICENSE.txt +674 -21
- data/README.md +80 -443
- data/bin/console +19 -0
- data/bin/setup +20 -0
- data/docs/404.html +639 -0
- data/docs/advanced/automatic_updates/index.html +791 -0
- data/docs/advanced/command_types/index.html +946 -0
- data/docs/advanced/distributed_state_locking/index.html +777 -0
- data/docs/advanced/hooks/index.html +836 -0
- data/docs/advanced/state_storage/index.html +957 -0
- data/docs/advanced/user_config_files/index.html +818 -0
- data/docs/assets/fonts/font-awesome.css +4 -0
- data/docs/assets/fonts/material-icons.css +13 -0
- data/docs/assets/fonts/specimen/FontAwesome.ttf +0 -0
- data/docs/assets/fonts/specimen/FontAwesome.woff +0 -0
- data/docs/assets/fonts/specimen/FontAwesome.woff2 +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.ttf +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff2 +0 -0
- data/docs/assets/images/favicon.png +0 -0
- data/docs/assets/images/icons/bitbucket.1b09e088.svg +20 -0
- data/docs/assets/images/icons/github.f0b8504a.svg +18 -0
- data/docs/assets/images/icons/gitlab.6dd19c00.svg +38 -0
- data/docs/assets/javascripts/application.a59e2a89.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.da.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.de.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.du.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.es.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.fi.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.fr.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.hu.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.it.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.jp.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.multi.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.no.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.pt.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.ro.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.ru.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.stemmer.support.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.sv.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.tr.js +1 -0
- data/docs/assets/javascripts/lunr/tinyseg.js +1 -0
- data/docs/assets/javascripts/modernizr.1aa3b519.js +1 -0
- data/docs/assets/stylesheets/application-palette.6079476c.css +2 -0
- data/docs/assets/stylesheets/application.ba0fd1a6.css +2 -0
- data/docs/development/code_of_conduct/index.html +883 -0
- data/docs/development/contributing/index.html +744 -0
- data/docs/development/license/index.html +715 -0
- data/docs/imported/changelog/index.html +853 -0
- data/docs/imported/quick_reference/index.html +1057 -0
- data/docs/index.html +732 -0
- data/docs/search/search_index.json +569 -0
- data/docs/sitemap.xml +93 -0
- data/docs/tutorial/10-getting_started/index.html +806 -0
- data/docs/tutorial/20-project_layout/index.html +972 -0
- data/docs/tutorial/30-your_first_command/index.html +906 -0
- data/docs/tutorial/40-options_parameters_and_arguments/index.html +1049 -0
- data/docs/tutorial/50-publishing/index.html +838 -0
- data/docs/whoami/index.html +709 -0
- data/docs-src/docs/advanced/automatic_updates.md +42 -0
- data/docs-src/docs/advanced/command_types.md +144 -0
- data/docs-src/docs/advanced/distributed_state_locking.md +33 -0
- data/docs-src/docs/advanced/hooks.md +65 -0
- data/docs-src/docs/advanced/logging.md +35 -0
- data/docs-src/docs/advanced/state_storage.md +117 -0
- data/docs-src/docs/advanced/user_config_files.md +47 -0
- data/docs-src/docs/development/code_of_conduct.md +74 -0
- data/docs-src/docs/development/contributing.md +49 -0
- data/docs-src/docs/development/license.md +10 -0
- data/docs-src/docs/imported/changelog.md +31 -0
- data/docs-src/docs/imported/quick_reference.md +150 -0
- data/docs-src/docs/index.md +38 -0
- data/docs-src/docs/tutorial/10-getting_started.md +41 -0
- data/docs-src/docs/tutorial/20-project_layout.md +115 -0
- data/docs-src/docs/tutorial/30-your_first_command.md +126 -0
- data/docs-src/docs/tutorial/40-options_parameters_and_arguments.md +251 -0
- data/docs-src/docs/tutorial/50-publishing.md +47 -0
- data/docs-src/docs/whoami.md +28 -0
- data/docs-src/makesite.sh +14 -0
- data/docs-src/mkdocs.yml +76 -0
- data/docs-src/runsite.sh +3 -0
- data/exe/rbcli +76 -5
- data/lib/rbcli/autoupdate/autoupdate.rb +24 -4
- data/lib/rbcli/autoupdate/gem_updater.rb +23 -2
- data/lib/rbcli/autoupdate/github_updater.rb +22 -1
- data/lib/rbcli/configuration/config.rb +22 -1
- data/lib/rbcli/configuration/configurate.rb +24 -2
- data/lib/rbcli/engine/command.rb +26 -6
- data/lib/rbcli/engine/load_project.rb +29 -3
- data/lib/rbcli/engine/parser.rb +25 -4
- data/lib/rbcli/logging/logging.rb +21 -0
- data/lib/rbcli/scriptwrapping/scriptwrapper.rb +30 -11
- data/lib/rbcli/stateful_systems/configuratestorage.rb +20 -0
- data/lib/rbcli/stateful_systems/state_storage.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/localstate.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/remote_state_connectors/dynamodb.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb +20 -0
- data/lib/rbcli/util/hash_deep_symbolize.rb +43 -22
- data/lib/rbcli/util/string_colorize.rb +20 -0
- data/lib/rbcli/version.rb +21 -1
- data/lib/rbcli-tool/generators.rb +20 -0
- data/lib/rbcli-tool/mdless_fix.rb +20 -0
- data/lib/rbcli-tool/project.rb +27 -2
- data/lib/rbcli-tool/util.rb +20 -0
- data/lib/rbcli-tool.rb +20 -0
- data/lib/rbcli.rb +20 -0
- data/lib-sh/lib-rbcli.sh +19 -0
- data/rbcli.gemspec +22 -3
- data/skeletons/project/CODE_OF_CONDUCT.md +1 -1
- data/skeletons/project/README.md +17 -2
- data/skeletons/project/application/commands/command.erb +10 -8
- data/skeletons/project/application/commands/script.erb +3 -1
- data/skeletons/project/application/commands/scripts/script.sh +2 -2
- data/skeletons/project/application/options.rb +12 -3
- data/skeletons/project/config/autoupdate.rb +5 -2
- data/skeletons/project/config/storage.rb +7 -6
- data/skeletons/project/config/userspace.rb +6 -1
- data/skeletons/project/exe/executable +1 -1
- data/skeletons/project/lib/.keep +0 -0
- data/skeletons/project/untitled.gemspec +4 -4
- data/skeletons/project/{default_user_configs → userconf}/user_defaults.yml +0 -0
- metadata +85 -9
- data/examples/defaults.yml +0 -4
- data/examples/myscript.sh +0 -23
- data/examples/mytool +0 -95
@@ -1,12 +1,33 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
require 'octokit'
|
2
22
|
|
3
23
|
module Rbcli::Autoupdate
|
4
24
|
class GithubUpdater
|
5
25
|
include Common
|
6
26
|
|
7
|
-
def initialize reponame, access_token, enterprise_hostname, force_update
|
27
|
+
def initialize reponame, access_token, enterprise_hostname, force_update, message
|
8
28
|
@reponame = reponame
|
9
29
|
@force_update = force_update
|
30
|
+
@message = message
|
10
31
|
|
11
32
|
access_token = Rbcli.config.key?(:github_updatecheck) ? (Rbcli.config[:github_updatecheck][:access_token] || access_token) : access_token
|
12
33
|
enterprise_hostname = Rbcli.config.key?(:github_updatecheck) ? (Rbcli.config[:github_updatecheck][:enterprise_hostname] || enterprise_hostname) : enterprise_hostname
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
####
|
2
22
|
# Config Module
|
3
23
|
####
|
@@ -46,6 +66,7 @@ module Rbcli::Config
|
|
46
66
|
@loaded = false
|
47
67
|
|
48
68
|
def self.set_userfile filename, merge_defaults: true, required: false
|
69
|
+
return if filename.nil?
|
49
70
|
@config_file = File.expand_path filename
|
50
71
|
@merge_defaults = merge_defaults
|
51
72
|
@userfile_required = required
|
@@ -99,7 +120,7 @@ module Rbcli::Config
|
|
99
120
|
@config = YAML::load(File.read(@config_file)).deep_symbolize!
|
100
121
|
@config.deep_merge! @config_defaults if @merge_defaults
|
101
122
|
elsif @userfile_required
|
102
|
-
puts "User's config file not found at #{@config_file}. Please run this tool with the -
|
123
|
+
puts "User's config file not found at #{@config_file}. Please run this tool with the `--generate-config` option to generate it."
|
103
124
|
exit 1
|
104
125
|
else
|
105
126
|
@config = @config_defaults
|
@@ -1,3 +1,24 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
21
|
+
|
1
22
|
module Rbcli::Configurate
|
2
23
|
|
3
24
|
@data = {
|
@@ -63,14 +84,15 @@ module Rbcli::Configurate
|
|
63
84
|
@data[:allow_json] = allow_json
|
64
85
|
end
|
65
86
|
|
66
|
-
def self.option name, description, type: :boolean, default: nil, required: false, permitted: nil
|
87
|
+
def self.option name, description, short: nil, type: :boolean, default: nil, required: false, permitted: nil
|
67
88
|
default ||= false if (type == :boolean || type == :bool || type == :flag)
|
68
89
|
@data[:options][name.to_sym] = {
|
69
90
|
description: description,
|
70
91
|
type: type,
|
71
92
|
default: default,
|
72
93
|
required: required,
|
73
|
-
permitted: permitted
|
94
|
+
permitted: permitted,
|
95
|
+
short: short
|
74
96
|
}
|
75
97
|
end
|
76
98
|
|
data/lib/rbcli/engine/command.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
21
|
+
|
1
22
|
class Rbcli::Command
|
2
23
|
|
3
24
|
#include InheritableTraits
|
@@ -29,7 +50,7 @@ class Rbcli::Command
|
|
29
50
|
def self.action █ @action = block end
|
30
51
|
def action; self.class.instance_variable_get :@action end
|
31
52
|
|
32
|
-
def self.parameter name, description, type: :boolean, default: nil, required: false, permitted: nil
|
53
|
+
def self.parameter name, description, short: nil, type: :boolean, default: nil, required: false, permitted: nil
|
33
54
|
default ||= false if (type == :boolean || type == :bool || type == :flag)
|
34
55
|
@paramlist ||= {}
|
35
56
|
@paramlist[name.to_sym] = {
|
@@ -37,7 +58,8 @@ class Rbcli::Command
|
|
37
58
|
type: type,
|
38
59
|
default: default,
|
39
60
|
required: required,
|
40
|
-
permitted: permitted
|
61
|
+
permitted: permitted,
|
62
|
+
short: short
|
41
63
|
}
|
42
64
|
end
|
43
65
|
def paramlist; self.class.instance_variable_get :@paramlist end
|
@@ -98,13 +120,11 @@ Selected Command:
|
|
98
120
|
|
99
121
|
Usage:
|
100
122
|
#{data[:scriptname]} [options] #{command_name} [parameters]
|
101
|
-
|
102
|
-
#{command_usage}
|
103
|
-
|
123
|
+
#{if command_usage then "\n" + command_usage + "\n" end}
|
104
124
|
Command-specific Parameters:
|
105
125
|
EOS
|
106
126
|
params.each do |name, opts|
|
107
|
-
opt name, opts[:description], type: opts[:type], default: opts[:default], required: opts[:required], permitted: opts[:permitted]
|
127
|
+
opt name, opts[:description], type: opts[:type], default: opts[:default], required: opts[:required], permitted: opts[:permitted], short: opts[:short]
|
108
128
|
end if params.is_a? Hash
|
109
129
|
end
|
110
130
|
optx[:args] = ARGV
|
@@ -1,6 +1,31 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
21
|
+
|
1
22
|
module Rbcli
|
2
23
|
def self.load_project
|
3
|
-
project_root = File.expand_path
|
24
|
+
project_root = File.expand_path("#{File.dirname(caller[0].split(':')[0])}/../")
|
25
|
+
|
26
|
+
# Add lib to the load path for the user's convenience
|
27
|
+
lib = "#{project_root}/lib"
|
28
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
29
|
|
5
30
|
# We require all ruby files as-is
|
6
31
|
%w(config hooks application application/commands).each do |dir|
|
@@ -11,9 +36,10 @@ module Rbcli
|
|
11
36
|
end
|
12
37
|
|
13
38
|
# We automatically pull in default user configs
|
14
|
-
configspath = "#{project_root}/
|
15
|
-
Dir.glob "#{configspath}/*.{yml,yaml}" do |file|
|
39
|
+
configspath = "#{project_root}/userconf"
|
40
|
+
Dir.glob "#{configspath}/*.{yml,yaml,json}" do |file|
|
16
41
|
Rbcli::Configurate.me {config_defaults file}
|
17
42
|
end
|
43
|
+
|
18
44
|
end
|
19
45
|
end
|
data/lib/rbcli/engine/parser.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
21
|
+
|
1
22
|
#TODO: Change this once the changes have been merged into trollop gem proper
|
2
23
|
require "rbcli/util/trollop"
|
3
24
|
|
@@ -25,11 +46,11 @@ Commands:
|
|
25
46
|
opts[:default] = nil unless opts.key? :default
|
26
47
|
opts[:required] = false unless opts.key? :required
|
27
48
|
opts[:permitted] = nil unless opts.key? :permitted
|
28
|
-
opt name.to_sym, opts[:description], type: opts[:type], default: opts[:default], required: opts[:required], permitted: opts[:permitted]
|
49
|
+
opt name.to_sym, opts[:description], type: opts[:type], default: opts[:default], required: opts[:required], permitted: opts[:permitted], short: opts[:short]
|
29
50
|
end
|
30
|
-
opt :json_output, 'Output result in machine-friendly JSON format', :
|
31
|
-
opt :config_file, 'Specify a config file manually', :
|
32
|
-
opt :generate_config, 'Generate a new config file' unless data[:config_userfile].nil? #defaults to false
|
51
|
+
opt :json_output, 'Output result in machine-friendly JSON format', type: :boolean, default: false if data[:allow_json]
|
52
|
+
opt :config_file, 'Specify a config file manually', short: :none, type: :string, default: data[:config_userfile] unless data[:config_userfile].nil?
|
53
|
+
opt :generate_config, 'Generate a new config file', short: :none unless data[:config_userfile].nil? #defaults to false
|
33
54
|
stop_on Rbcli::Command.commands.keys
|
34
55
|
end
|
35
56
|
|
@@ -1,3 +1,24 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
21
|
+
|
1
22
|
####
|
2
23
|
# Logging Module
|
3
24
|
####
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
class Rbcli::Command
|
2
22
|
def self.extern path: nil, envvars: nil, &block
|
3
23
|
if path == :default
|
@@ -8,7 +28,7 @@ class Rbcli::Command
|
|
8
28
|
@extern = Rbcli::Scriptwrapper.new path, envvars, block
|
9
29
|
end
|
10
30
|
|
11
|
-
def extern
|
31
|
+
def extern
|
12
32
|
@extern ||= nil
|
13
33
|
self.class.instance_variable_get :@extern
|
14
34
|
end
|
@@ -40,18 +60,18 @@ class Rbcli::Scriptwrapper
|
|
40
60
|
# end
|
41
61
|
# env_hash.merge!(@envvars.deep_stringify!) unless @envvars.nil?
|
42
62
|
|
43
|
-
env_hash = {
|
44
|
-
'__RBCLI_PARAMS' => params.to_json,
|
45
|
-
'__RBCLI_ARGS' => args.to_json,
|
46
|
-
'__RBCLI_GLOBAL' => global_opts.to_json,
|
47
|
-
'__RBCLI_CONFIG' => config.to_json,
|
48
|
-
'__RBCLI_MYVARS' => @envvars.to_json
|
49
|
-
}
|
50
|
-
|
51
63
|
if @block
|
64
|
+
env_hash = {
|
65
|
+
'__RBCLI_PARAMS' => params.to_json,
|
66
|
+
'__RBCLI_ARGS' => args.to_json,
|
67
|
+
'__RBCLI_GLOBAL' => global_opts.to_json,
|
68
|
+
'__RBCLI_CONFIG' => config.to_json,
|
69
|
+
'__RBCLI_MYVARS' => @envvars.to_json
|
70
|
+
}
|
52
71
|
path = @block.call params, args, global_opts, config
|
72
|
+
system(env_hash, path)
|
53
73
|
else
|
54
|
-
|
74
|
+
system(@envvars, @path)
|
55
75
|
end
|
56
76
|
|
57
77
|
# IO.popen(env_hash, path) do |io|
|
@@ -59,7 +79,6 @@ class Rbcli::Scriptwrapper
|
|
59
79
|
# puts line
|
60
80
|
# end
|
61
81
|
# end
|
62
|
-
system(env_hash, path)
|
63
82
|
end
|
64
83
|
|
65
84
|
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
module Rbcli::Configurate
|
2
22
|
def self.storage &block
|
3
23
|
Rbcli::ConfigurateStorage.configure &block
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
require 'fileutils'
|
2
22
|
require 'json'
|
3
23
|
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
require 'fileutils'
|
2
22
|
require 'json'
|
3
23
|
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
require 'aws-sdk-dynamodb'
|
2
22
|
require 'macaddr'
|
3
23
|
require 'digest/sha2'
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
## Configuration Interface
|
2
22
|
module Rbcli::ConfigurateStorage
|
3
23
|
@data[:remotestate] = nil
|
@@ -1,28 +1,49 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
21
|
+
|
1
22
|
##
|
2
23
|
# Functions to convert hash keys to all symbols or all strings
|
3
24
|
##
|
4
25
|
class Hash
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
26
|
+
def deep_symbolize! hsh = nil
|
27
|
+
hsh ||= self
|
28
|
+
hsh.keys.each do |k|
|
29
|
+
if k.is_a? String
|
30
|
+
hsh[k.to_sym] = hsh[k]
|
31
|
+
hsh.delete k
|
32
|
+
end
|
33
|
+
deep_symbolize! hsh[k.to_sym] if hsh[k.to_sym].is_a? Hash
|
34
|
+
end
|
35
|
+
hsh
|
36
|
+
end
|
16
37
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
38
|
+
def deep_stringify! hsh = nil
|
39
|
+
hsh ||= self
|
40
|
+
hsh.keys.each do |k|
|
41
|
+
if k.is_a? Symbol
|
42
|
+
hsh[k.to_s] = hsh[k]
|
43
|
+
hsh.delete k
|
44
|
+
end
|
45
|
+
deep_stringify! hsh[k.to_s] if hsh[k.to_s].is_a? Hash
|
46
|
+
end
|
47
|
+
hsh
|
48
|
+
end
|
28
49
|
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
class String
|
2
22
|
def black; "\e[30m#{self}\e[0m" end
|
3
23
|
def red; "\e[31m#{self}\e[0m" end
|
data/lib/rbcli/version.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
module Rbcli
|
2
|
-
|
22
|
+
VERSION = "0.2.0"
|
3
23
|
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# RBCli -- A framework for developing command line applications in Ruby #
|
3
|
+
# Copyright (C) 2018 Andrew Khoury #
|
4
|
+
# #
|
5
|
+
# This program is free software: you can redistribute it and/or modify #
|
6
|
+
# it under the terms of the GNU General Public License as published by #
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or #
|
8
|
+
# (at your option) any later version. #
|
9
|
+
# #
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
13
|
+
# GNU General Public License for more details. #
|
14
|
+
# #
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
|
+
# #
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
|
+
##################################################################################
|
20
|
+
|
1
21
|
module RBCliTool
|
2
22
|
class Generator
|
3
23
|
def self.inherited(subklass)
|