rbcli 0.2.0 → 0.2.1
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/CHANGELOG.md +12 -1
- data/Gemfile.lock +7 -2
- data/README.md +43 -3
- data/bin/console +1 -1
- data/bin/setup +1 -1
- data/docs/404.html +12 -0
- data/docs/advanced/automatic_updates/index.html +12 -0
- data/docs/advanced/command_types/index.html +13 -1
- data/docs/advanced/distributed_state_locking/index.html +14 -2
- data/docs/advanced/hooks/index.html +12 -0
- data/docs/advanced/remote_execution/index.html +822 -0
- data/docs/advanced/state_storage/index.html +12 -0
- data/docs/advanced/user_config_files/index.html +12 -0
- data/docs/development/code_of_conduct/index.html +12 -0
- data/docs/development/contributing/index.html +15 -3
- data/docs/development/license/index.html +12 -0
- data/docs/imported/changelog/index.html +82 -7
- data/docs/imported/quick_reference/index.html +40 -1
- data/docs/index.html +15 -0
- data/docs/search/search_index.json +52 -12
- data/docs/sitemap.xml +23 -18
- data/docs/tutorial/10-getting_started/index.html +12 -0
- data/docs/tutorial/20-project_layout/index.html +12 -0
- data/docs/tutorial/30-your_first_command/index.html +12 -0
- data/docs/tutorial/40-options_parameters_and_arguments/index.html +12 -0
- data/docs/tutorial/50-publishing/index.html +12 -0
- data/docs/whoami/index.html +12 -0
- data/docs-src/docs/advanced/command_types.md +1 -1
- data/docs-src/docs/advanced/remote_execution.md +56 -0
- data/docs-src/docs/development/contributing.md +1 -1
- data/docs-src/docs/imported/changelog.md +12 -1
- data/docs-src/docs/imported/quick_reference.md +23 -1
- data/docs-src/docs/index.md +2 -0
- data/docs-src/mkdocs.yml +1 -0
- data/exe/rbcli +1 -1
- data/lib/rbcli/autoupdate/autoupdate.rb +1 -1
- data/lib/rbcli/autoupdate/gem_updater.rb +1 -1
- data/lib/rbcli/autoupdate/github_updater.rb +1 -1
- data/lib/rbcli/configuration/config.rb +1 -1
- data/lib/rbcli/configuration/configurate.rb +7 -2
- data/lib/rbcli/engine/command.rb +25 -3
- data/lib/rbcli/engine/load_project.rb +1 -1
- data/lib/rbcli/engine/parser.rb +10 -2
- data/lib/rbcli/logging/logging.rb +1 -1
- data/lib/rbcli/remote_exec/remote_exec.rb +187 -0
- data/lib/rbcli/scriptwrapping/scriptwrapper.rb +25 -5
- data/lib/rbcli/stateful_systems/configuratestorage.rb +1 -1
- data/lib/rbcli/stateful_systems/state_storage.rb +1 -1
- data/lib/rbcli/stateful_systems/storagetypes/localstate.rb +1 -1
- data/lib/rbcli/stateful_systems/storagetypes/remote_state_connectors/dynamodb.rb +1 -1
- data/lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb +1 -1
- data/lib/rbcli/util/hash_deep_symbolize.rb +1 -1
- data/lib/rbcli/util/string_colorize.rb +1 -1
- data/lib/rbcli/version.rb +2 -2
- data/lib/rbcli-tool/generators.rb +1 -1
- data/lib/rbcli-tool/mdless_fix.rb +1 -1
- data/lib/rbcli-tool/project.rb +1 -1
- data/lib/rbcli-tool/util.rb +1 -1
- data/lib/rbcli-tool.rb +1 -1
- data/lib/rbcli.rb +5 -1
- data/lib-sh/lib-rbcli.sh +18 -9
- data/rbcli.gemspec +5 -2
- data/skeletons/project/application/commands/command.erb +1 -1
- data/skeletons/project/application/commands/script.erb +11 -7
- data/skeletons/project/application/options.rb +0 -5
- data/skeletons/project/config/general.rb +17 -0
- metadata +35 -3
@@ -0,0 +1,187 @@
|
|
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
|
+
require 'net/ssh'
|
22
|
+
require 'net/scp'
|
23
|
+
require 'json'
|
24
|
+
|
25
|
+
class Rbcli::RemoteExec
|
26
|
+
|
27
|
+
def initialize cmd, connection_string, remote_identity, params, args, global_opts, config
|
28
|
+
@cmd = cmd
|
29
|
+
@params = params.to_json.gsub("\"", "\\\"")
|
30
|
+
@args = args.to_json.gsub("\"", "\\\"")
|
31
|
+
@global_opts = global_opts.to_json.gsub("\"", "\\\"")
|
32
|
+
@config = config.to_json.gsub("\"", "\\\"")
|
33
|
+
|
34
|
+
@remote_host = parse_connection connection_string, remote_identity
|
35
|
+
|
36
|
+
## SCRIPT COMMANDS
|
37
|
+
if !@cmd.script.nil?
|
38
|
+
@execution_block = lambda do |ssh|
|
39
|
+
# Set paths
|
40
|
+
tmpdir = ssh.exec! 'mktemp -d /tmp/rbcli.XXXXXXXXXXXX'
|
41
|
+
remote_script_path = "#{tmpdir.strip}/script.sh"
|
42
|
+
local_rbclilib_path = "#{File.dirname(__FILE__)}/../../../lib-sh/lib-rbcli.sh"
|
43
|
+
remote_rbclilib_path = "#{tmpdir.strip}/lib-rbcli.sh"
|
44
|
+
|
45
|
+
# Upload scripts
|
46
|
+
ssh.scp.upload @cmd.script.path, remote_script_path
|
47
|
+
ssh.scp.upload local_rbclilib_path, remote_rbclilib_path
|
48
|
+
ssh.exec! "chmod 0700 #{remote_script_path}"
|
49
|
+
|
50
|
+
# We need to test for JQ -- if it is not present we ask the user for the sudo password
|
51
|
+
jq_found = ssh.exec!('which jq').exitstatus == 0
|
52
|
+
if jq_found
|
53
|
+
sudopw = nil
|
54
|
+
else
|
55
|
+
print "JQ not found on remote system. Please enter sudo password to install it, or leave blank if no password needed: "
|
56
|
+
sudopw = gets.chomp
|
57
|
+
end
|
58
|
+
|
59
|
+
# Since we need to sudo, we need to send the sudo password when prompted
|
60
|
+
#result = ''
|
61
|
+
channel = ssh.open_channel do |channel, success|
|
62
|
+
channel.on_data do |channel, data|
|
63
|
+
print data.to_s
|
64
|
+
if !jq_found and data =~ /^\[sudo\] password for /
|
65
|
+
channel.send_data "#{sudopw}\n"
|
66
|
+
# else
|
67
|
+
# result += data.to_s
|
68
|
+
end
|
69
|
+
end
|
70
|
+
channel.request_pty
|
71
|
+
channel.exec "__RBCLI_PARAMS=\"#{@params}\" __RBCLI_ARGS=\"#{@args}\" __RBCLI_GLOBAL=\"#{@global_opts}\" __RBCLI_CONFIG=\"#{@config}\" source #{remote_script_path}"
|
72
|
+
channel.wait
|
73
|
+
end
|
74
|
+
channel.wait
|
75
|
+
#puts result
|
76
|
+
|
77
|
+
# Cleanup
|
78
|
+
ssh.exec! "rm -rf #{tmpdir}"
|
79
|
+
end
|
80
|
+
|
81
|
+
## EXTERN COMMANDS
|
82
|
+
elsif !@cmd.extern.nil?
|
83
|
+
@execution_block = lambda do |ssh|
|
84
|
+
channel = ssh.open_channel do |channel, success|
|
85
|
+
channel.on_data do |channel, data|
|
86
|
+
print data.to_s
|
87
|
+
end
|
88
|
+
channel.request_pty
|
89
|
+
channel.exec "__RBCLI_PARAMS=\"#{@params}\" __RBCLI_ARGS=\"#{@args}\" __RBCLI_GLOBAL=\"#{@global_opts}\" __RBCLI_CONFIG=\"#{@config}\" __RBCLI_MYVARS=\"#{@myvars}\" #{@cmd.extern.path}"
|
90
|
+
channel.wait
|
91
|
+
end
|
92
|
+
channel.wait
|
93
|
+
end
|
94
|
+
|
95
|
+
## STANDARD COMMANDS
|
96
|
+
else
|
97
|
+
@execution_block = lambda do |ssh|
|
98
|
+
raise Exception.new "Warning: Remote SSH Execution does not yetexist for Standard Ruby commands. Please use a Script or External command to use this feature."
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
def run
|
105
|
+
|
106
|
+
case @remote_host[:credstype]
|
107
|
+
when :keyfile
|
108
|
+
Net::SSH.start(@remote_host[:hostname], @remote_host[:username], port: @remote_host[:port], keys: @remote_host[:creds], keys_only: true, &@execution_block)
|
109
|
+
when :keytext
|
110
|
+
Net::SSH.start(@remote_host[:hostname], @remote_host[:username], port: @remote_host[:port], key_data: @remote_host[:creds], keys_only: true, &@execution_block)
|
111
|
+
when :password
|
112
|
+
Net::SSH.start(@remote_host[:hostname], @remote_host[:username], port: @remote_host[:port], password: @remote_host[:creds], keys_only: false, &@execution_block)
|
113
|
+
else
|
114
|
+
raise Exception.new "Invalid SSH Connection: No credentials specified for host #{@remote_host[:hostname]}"
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def parse_connection connstring, ident
|
122
|
+
## We want to split the connection string up
|
123
|
+
_, _, user, host, _, port = connstring.match(/^(([^:@\/]+)@)?([^:@\/]+)?(:([\d]+))?/).to_a
|
124
|
+
exiting = false
|
125
|
+
if host.nil?
|
126
|
+
puts "Please enter a valid hostname or IP address for remote execution."
|
127
|
+
exiting = true
|
128
|
+
end
|
129
|
+
begin
|
130
|
+
port ||= 22
|
131
|
+
port = port.to_i
|
132
|
+
rescue
|
133
|
+
puts "Please enter a valid port number"
|
134
|
+
exiting = true
|
135
|
+
end
|
136
|
+
exit 1 if exiting
|
137
|
+
|
138
|
+
if File.exist? File.expand_path(ident)
|
139
|
+
credstype = :keyfile
|
140
|
+
else
|
141
|
+
credstype = :password
|
142
|
+
end
|
143
|
+
|
144
|
+
{
|
145
|
+
hostname: host,
|
146
|
+
port: port,
|
147
|
+
username: user,
|
148
|
+
creds: ident,
|
149
|
+
credstype: credstype
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
# class Rbcli::Command
|
157
|
+
#
|
158
|
+
# def self.remote_exec cmd, params, args, global_opts, config
|
159
|
+
# executor = Rbcli::RemoteExec.new cmd, cmd.remote_host, params, args, global_opts, config
|
160
|
+
# executor.run
|
161
|
+
# end
|
162
|
+
#
|
163
|
+
# def self.remote_host hostname, port: 22, username: nil, password: nil, keytext: nil, keyfile: nil
|
164
|
+
# @remote_host = {
|
165
|
+
# hostname: hostname,
|
166
|
+
# port: port,
|
167
|
+
# username: username,
|
168
|
+
# creds: keyfile || keytext || password,
|
169
|
+
# credstype: (keyfile.nil?) ? ((keytext.nil?) ? ((password.nil?) ? nil : :password) : :keytext) : :keyfile
|
170
|
+
# }
|
171
|
+
# end
|
172
|
+
#
|
173
|
+
# def remote_host
|
174
|
+
# self.class.instance_variable_get :@remote_host
|
175
|
+
# end
|
176
|
+
#
|
177
|
+
# ##
|
178
|
+
# # Run command on a remote machine
|
179
|
+
# ##
|
180
|
+
# def self.remote_cmd cmd, params, args, global_opts, config
|
181
|
+
# # We do something different depending on if it is a Ruby command, Script, or Extern
|
182
|
+
# unless @commands[cmd].script.nil?
|
183
|
+
# script = @commands[cmd].script
|
184
|
+
#
|
185
|
+
# end
|
186
|
+
# end
|
187
|
+
# end
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
class Rbcli::Command
|
@@ -32,16 +32,32 @@ class Rbcli::Command
|
|
32
32
|
@extern ||= nil
|
33
33
|
self.class.instance_variable_get :@extern
|
34
34
|
end
|
35
|
+
|
36
|
+
def self.script path: nil, envvars: nil
|
37
|
+
if path == :default or path.nil?
|
38
|
+
callerscript = caller_locations.first.absolute_path
|
39
|
+
path = "#{File.dirname(callerscript)}/scripts/#{File.basename(callerscript, ".*")}.sh"
|
40
|
+
end
|
41
|
+
@script = Rbcli::Scriptwrapper.new path, envvars, nil, true
|
42
|
+
end
|
43
|
+
|
44
|
+
def script
|
45
|
+
@script ||= nil
|
46
|
+
self.class.instance_variable_get :@script
|
47
|
+
end
|
35
48
|
end
|
36
49
|
|
37
50
|
require 'json'
|
38
51
|
class Rbcli::Scriptwrapper
|
39
|
-
def initialize path, envvars = nil, block = nil
|
52
|
+
def initialize path, envvars = nil, block = nil, script = false
|
40
53
|
@path = path
|
41
54
|
@envvars = envvars || {}
|
42
55
|
@block = block
|
56
|
+
@script = script
|
43
57
|
end
|
44
58
|
|
59
|
+
attr_reader :path
|
60
|
+
|
45
61
|
def execute params, args, global_opts, config
|
46
62
|
####
|
47
63
|
#### The following code will flatten one level of the hashes into separate variables
|
@@ -60,7 +76,7 @@ class Rbcli::Scriptwrapper
|
|
60
76
|
# end
|
61
77
|
# env_hash.merge!(@envvars.deep_stringify!) unless @envvars.nil?
|
62
78
|
|
63
|
-
if @block
|
79
|
+
if @block || @script
|
64
80
|
env_hash = {
|
65
81
|
'__RBCLI_PARAMS' => params.to_json,
|
66
82
|
'__RBCLI_ARGS' => args.to_json,
|
@@ -68,10 +84,14 @@ class Rbcli::Scriptwrapper
|
|
68
84
|
'__RBCLI_CONFIG' => config.to_json,
|
69
85
|
'__RBCLI_MYVARS' => @envvars.to_json
|
70
86
|
}
|
71
|
-
|
87
|
+
if @block
|
88
|
+
path = @block.call params, args, global_opts, config
|
89
|
+
else
|
90
|
+
path = @path
|
91
|
+
end
|
72
92
|
system(env_hash, path)
|
73
93
|
else
|
74
|
-
system(@envvars, @path)
|
94
|
+
system(@envvars.collect{|k,v| [k.to_s, v]}.to_h, @path)
|
75
95
|
end
|
76
96
|
|
77
97
|
# IO.popen(env_hash, path) do |io|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
module Rbcli::Configurate
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
require 'fileutils'
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
require 'fileutils'
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
require 'aws-sdk-dynamodb'
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
## Configuration Interface
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
class String
|
data/lib/rbcli/version.rb
CHANGED
@@ -15,9 +15,9 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
module Rbcli
|
22
|
-
VERSION = "0.2.
|
22
|
+
VERSION = "0.2.1"
|
23
23
|
end
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
module RBCliTool
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
require 'mdless'
|
data/lib/rbcli-tool/project.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
module RBCliTool
|
data/lib/rbcli-tool/util.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
require 'erb'
|
data/lib/rbcli-tool.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
###########
|
data/lib/rbcli.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
###########
|
@@ -60,6 +60,10 @@ require 'rbcli/autoupdate/autoupdate'
|
|
60
60
|
require 'rbcli/scriptwrapping/scriptwrapper'
|
61
61
|
# END SCRIPT WRAPPER
|
62
62
|
|
63
|
+
# REMOTE EXEC
|
64
|
+
require 'rbcli/remote_exec/remote_exec'
|
65
|
+
# END REMOTE EXEC
|
66
|
+
|
63
67
|
# CORE
|
64
68
|
require 'rbcli/configuration/configurate'
|
65
69
|
require 'rbcli/engine/load_project'
|
data/lib-sh/lib-rbcli.sh
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
# You should have received a copy of the GNU General Public License #
|
17
17
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
18
18
|
# #
|
19
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
19
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
20
20
|
##################################################################################
|
21
21
|
|
22
22
|
## Log message
|
@@ -51,14 +51,23 @@ function detect_os {
|
|
51
51
|
## Install JQ
|
52
52
|
function install_jq {
|
53
53
|
case "$(detect_os)}" in
|
54
|
-
Linux)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
Linux*)
|
55
|
+
_flavor=$(cat /etc/*release | grep "DISTRIB_ID" | cut -d'=' -f2)
|
56
|
+
case "${_flavor}" in
|
57
|
+
Ubuntu*)
|
58
|
+
sudo apt-get install jq -y
|
59
|
+
;;
|
60
|
+
*)
|
61
|
+
_tmpdir=$(mktemp -d)
|
62
|
+
_pwd=$(pwd)
|
63
|
+
cd $_tmpdir
|
64
|
+
curl -sOL "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64"
|
65
|
+
sudo mv jq-linux64 /usr/bin/jq
|
66
|
+
sudo chmod +x /usr/bin/jq
|
67
|
+
cd $_pwd
|
68
|
+
rm -rf $_tmpdir
|
69
|
+
;;
|
70
|
+
esac
|
62
71
|
;;
|
63
72
|
Darwin*)
|
64
73
|
message "Apple OSX Detected; homebrew must be installed to continue. Continue? (Y/n): " "no_newline"
|
data/rbcli.gemspec
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# You should have received a copy of the GNU General Public License #
|
16
16
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
17
17
|
# #
|
18
|
-
# For questions regarding licensing, please contact andrew@blacknex.us
|
18
|
+
# For questions regarding licensing, please contact andrew@blacknex.us #
|
19
19
|
##################################################################################
|
20
20
|
|
21
21
|
lib = File.expand_path("../lib", __FILE__)
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.summary = %q{A CLI Application/Tooling Framework for Ruby}
|
32
32
|
spec.description = %q{RBCli is a framework to quickly develop command-line tools and applications.}
|
33
|
-
spec.homepage = 'https://github.
|
33
|
+
spec.homepage = 'https://akhoury6.github.io/rbcli'
|
34
34
|
spec.license = 'MIT'
|
35
35
|
|
36
36
|
spec.required_ruby_version = '>= 2.3'
|
@@ -64,6 +64,9 @@ Gem::Specification.new do |spec|
|
|
64
64
|
spec.add_dependency 'rufus-scheduler', '~> 3.5'
|
65
65
|
spec.add_dependency 'octokit', '~> 4.9'
|
66
66
|
spec.add_dependency 'mdless', '~> 0.0'
|
67
|
+
spec.add_dependency 'net-ssh', '~> 5.0'
|
68
|
+
spec.add_dependency 'net-scp', '~> 1.2'
|
69
|
+
|
67
70
|
|
68
71
|
#spec.add_dependency 'trollop', '~> 2.1'
|
69
72
|
end
|
@@ -9,7 +9,7 @@ class <%= @vars[:name].capitalize %> < Rbcli::Command
|
|
9
9
|
description '<%= @vars[:description] %>' # (Required) Short description for the global help
|
10
10
|
usage <<-EOF
|
11
11
|
<%= @vars[:usage_text] %>
|
12
|
-
EOF
|
12
|
+
EOF
|
13
13
|
parameter :force, 'Force testing', short: 'f', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Uses the same format as options (see application/options.rb for help)
|
14
14
|
|
15
15
|
config_default :myopt2, description: 'My Option #2', default: 'Default Value Here' # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config.
|
@@ -5,13 +5,17 @@
|
|
5
5
|
# from Rbcli::Command. The name of the class will be
|
6
6
|
# the command that is available to the user.
|
7
7
|
#########################
|
8
|
-
class <%= @vars[:name].capitalize %> < Rbcli::Command
|
9
|
-
description '<%= @vars[:description] %>'
|
10
|
-
usage
|
11
|
-
|
8
|
+
class <%= @vars[:name].capitalize %> < Rbcli::Command # Declare a new command by subclassing Rbcli::Command
|
9
|
+
description '<%= @vars[:description] %>' # (Required) Short description for the global help
|
10
|
+
usage <<-EOF
|
11
|
+
<%= @vars[:usage_text] %>
|
12
|
+
EOF
|
13
|
+
parameter :force, 'Force testing', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times
|
12
14
|
|
13
|
-
config_default :myopt2, description: 'Testing this again', default: true
|
14
|
-
# Alternatively, you can
|
15
|
+
config_default :myopt2, description: 'Testing this again', default: true # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config.
|
16
|
+
# Alternatively, you can create a yaml file in the `default_user_configs` directory in your project
|
17
|
+
|
18
|
+
#remote_permitted # (Optional) Allow this script to be executed on remote hosts. Requires enabling remote execution in the RBCli configuration
|
15
19
|
|
16
20
|
<% if @vars[:no_script] -%>
|
17
21
|
extern path: 'path/to/application', envvars: {MYVAR: 'some_value'} # (Required) Runs a given application, with optional environment variables, when the user runs the command.
|
@@ -21,6 +25,6 @@ class <%= @vars[:name].capitalize %> < Rbcli::Command
|
|
21
25
|
# cmd
|
22
26
|
#end
|
23
27
|
<% else -%>
|
24
|
-
|
28
|
+
script # (Required): Do not edit this line. Do delete it if you wish to manually specify a script path and set environment variables.
|
25
29
|
<% end -%>
|
26
30
|
end
|
@@ -29,11 +29,6 @@ Rbcli::Configurate.me do
|
|
29
29
|
# they are made available to your hooks and commands.
|
30
30
|
###
|
31
31
|
|
32
|
-
## Description -- (Required) -- A description that will appear when the user looks at the help with -h.
|
33
|
-
# This should describe what the application does, and if applicable, give some common usage examples.
|
34
|
-
# It can be as long as needed. Use a heredoc if desired: <<-EOF TextGoesHere EOF
|
35
|
-
description %q{<%= @vars[:description] %>}
|
36
|
-
|
37
32
|
## Option -- (Optional, Multiple) -- Add a global CLI Option
|
38
33
|
option :name, 'Give me your name', short: 'n', type: :string, default: 'Jack', required: false, permitted: ['Jack', 'Jill']
|
39
34
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Rbcli::Configurate.me do
|
2
|
+
####
|
3
|
+
# General Configuration
|
4
|
+
###
|
5
|
+
# Here you will find the general configuration options for RBCli.
|
6
|
+
###
|
7
|
+
|
8
|
+
## Description -- (Required) -- A description that will appear when the user looks at the help with -h.
|
9
|
+
# This should describe what the application does, and if applicable, give some common usage examples.
|
10
|
+
# It can be as long as needed. Use a heredoc if desired: <<-EOF TextGoesHere EOF
|
11
|
+
description %q{<%= @vars[:description] %>}
|
12
|
+
|
13
|
+
## Remote Exection -- (Optional) -- Enables executing commands on remote machines via SSH
|
14
|
+
# For any command that you would like to enable remote_execution for, you shoud also
|
15
|
+
# put the 'remote_permitted' directive in its declaration.
|
16
|
+
remote_execution permitted: false
|
17
|
+
end
|
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.
|
4
|
+
version: 0.2.1
|
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-08-
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,6 +150,34 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: net-ssh
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '5.0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '5.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: net-scp
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.2'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '1.2'
|
153
181
|
description: RBCli is a framework to quickly develop command-line tools and applications.
|
154
182
|
email:
|
155
183
|
- andrew@blacknex.us
|
@@ -174,6 +202,7 @@ files:
|
|
174
202
|
- docs-src/docs/advanced/distributed_state_locking.md
|
175
203
|
- docs-src/docs/advanced/hooks.md
|
176
204
|
- docs-src/docs/advanced/logging.md
|
205
|
+
- docs-src/docs/advanced/remote_execution.md
|
177
206
|
- docs-src/docs/advanced/state_storage.md
|
178
207
|
- docs-src/docs/advanced/user_config_files.md
|
179
208
|
- docs-src/docs/development/code_of_conduct.md
|
@@ -196,6 +225,7 @@ files:
|
|
196
225
|
- docs/advanced/command_types/index.html
|
197
226
|
- docs/advanced/distributed_state_locking/index.html
|
198
227
|
- docs/advanced/hooks/index.html
|
228
|
+
- docs/advanced/remote_execution/index.html
|
199
229
|
- docs/advanced/state_storage/index.html
|
200
230
|
- docs/advanced/user_config_files/index.html
|
201
231
|
- docs/assets/fonts/font-awesome.css
|
@@ -263,6 +293,7 @@ files:
|
|
263
293
|
- lib/rbcli/engine/load_project.rb
|
264
294
|
- lib/rbcli/engine/parser.rb
|
265
295
|
- lib/rbcli/logging/logging.rb
|
296
|
+
- lib/rbcli/remote_exec/remote_exec.rb
|
266
297
|
- lib/rbcli/scriptwrapping/scriptwrapper.rb
|
267
298
|
- lib/rbcli/stateful_systems/configuratestorage.rb
|
268
299
|
- lib/rbcli/stateful_systems/state_storage.rb
|
@@ -288,6 +319,7 @@ files:
|
|
288
319
|
- skeletons/project/application/commands/scripts/script.sh
|
289
320
|
- skeletons/project/application/options.rb
|
290
321
|
- skeletons/project/config/autoupdate.rb
|
322
|
+
- skeletons/project/config/general.rb
|
291
323
|
- skeletons/project/config/logging.rb
|
292
324
|
- skeletons/project/config/storage.rb
|
293
325
|
- skeletons/project/config/userspace.rb
|
@@ -302,7 +334,7 @@ files:
|
|
302
334
|
- skeletons/project/spec/untitled_spec.rb
|
303
335
|
- skeletons/project/untitled.gemspec
|
304
336
|
- skeletons/project/userconf/user_defaults.yml
|
305
|
-
homepage: https://github.
|
337
|
+
homepage: https://akhoury6.github.io/rbcli
|
306
338
|
licenses:
|
307
339
|
- MIT
|
308
340
|
metadata: {}
|