rbcli 0.1.10 → 0.2.0

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.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/Gemfile.lock +12 -12
  5. data/LICENSE.txt +674 -21
  6. data/README.md +80 -443
  7. data/bin/console +19 -0
  8. data/bin/setup +20 -0
  9. data/docs/404.html +639 -0
  10. data/docs/advanced/automatic_updates/index.html +791 -0
  11. data/docs/advanced/command_types/index.html +946 -0
  12. data/docs/advanced/distributed_state_locking/index.html +777 -0
  13. data/docs/advanced/hooks/index.html +836 -0
  14. data/docs/advanced/state_storage/index.html +957 -0
  15. data/docs/advanced/user_config_files/index.html +818 -0
  16. data/docs/assets/fonts/font-awesome.css +4 -0
  17. data/docs/assets/fonts/material-icons.css +13 -0
  18. data/docs/assets/fonts/specimen/FontAwesome.ttf +0 -0
  19. data/docs/assets/fonts/specimen/FontAwesome.woff +0 -0
  20. data/docs/assets/fonts/specimen/FontAwesome.woff2 +0 -0
  21. data/docs/assets/fonts/specimen/MaterialIcons-Regular.ttf +0 -0
  22. data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff +0 -0
  23. data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff2 +0 -0
  24. data/docs/assets/images/favicon.png +0 -0
  25. data/docs/assets/images/icons/bitbucket.1b09e088.svg +20 -0
  26. data/docs/assets/images/icons/github.f0b8504a.svg +18 -0
  27. data/docs/assets/images/icons/gitlab.6dd19c00.svg +38 -0
  28. data/docs/assets/javascripts/application.a59e2a89.js +1 -0
  29. data/docs/assets/javascripts/lunr/lunr.da.js +1 -0
  30. data/docs/assets/javascripts/lunr/lunr.de.js +1 -0
  31. data/docs/assets/javascripts/lunr/lunr.du.js +1 -0
  32. data/docs/assets/javascripts/lunr/lunr.es.js +1 -0
  33. data/docs/assets/javascripts/lunr/lunr.fi.js +1 -0
  34. data/docs/assets/javascripts/lunr/lunr.fr.js +1 -0
  35. data/docs/assets/javascripts/lunr/lunr.hu.js +1 -0
  36. data/docs/assets/javascripts/lunr/lunr.it.js +1 -0
  37. data/docs/assets/javascripts/lunr/lunr.jp.js +1 -0
  38. data/docs/assets/javascripts/lunr/lunr.multi.js +1 -0
  39. data/docs/assets/javascripts/lunr/lunr.no.js +1 -0
  40. data/docs/assets/javascripts/lunr/lunr.pt.js +1 -0
  41. data/docs/assets/javascripts/lunr/lunr.ro.js +1 -0
  42. data/docs/assets/javascripts/lunr/lunr.ru.js +1 -0
  43. data/docs/assets/javascripts/lunr/lunr.stemmer.support.js +1 -0
  44. data/docs/assets/javascripts/lunr/lunr.sv.js +1 -0
  45. data/docs/assets/javascripts/lunr/lunr.tr.js +1 -0
  46. data/docs/assets/javascripts/lunr/tinyseg.js +1 -0
  47. data/docs/assets/javascripts/modernizr.1aa3b519.js +1 -0
  48. data/docs/assets/stylesheets/application-palette.6079476c.css +2 -0
  49. data/docs/assets/stylesheets/application.ba0fd1a6.css +2 -0
  50. data/docs/development/code_of_conduct/index.html +883 -0
  51. data/docs/development/contributing/index.html +744 -0
  52. data/docs/development/license/index.html +715 -0
  53. data/docs/imported/changelog/index.html +853 -0
  54. data/docs/imported/quick_reference/index.html +1057 -0
  55. data/docs/index.html +732 -0
  56. data/docs/search/search_index.json +569 -0
  57. data/docs/sitemap.xml +93 -0
  58. data/docs/tutorial/10-getting_started/index.html +806 -0
  59. data/docs/tutorial/20-project_layout/index.html +972 -0
  60. data/docs/tutorial/30-your_first_command/index.html +906 -0
  61. data/docs/tutorial/40-options_parameters_and_arguments/index.html +1049 -0
  62. data/docs/tutorial/50-publishing/index.html +838 -0
  63. data/docs/whoami/index.html +709 -0
  64. data/docs-src/docs/advanced/automatic_updates.md +42 -0
  65. data/docs-src/docs/advanced/command_types.md +144 -0
  66. data/docs-src/docs/advanced/distributed_state_locking.md +33 -0
  67. data/docs-src/docs/advanced/hooks.md +65 -0
  68. data/docs-src/docs/advanced/logging.md +35 -0
  69. data/docs-src/docs/advanced/state_storage.md +117 -0
  70. data/docs-src/docs/advanced/user_config_files.md +47 -0
  71. data/docs-src/docs/development/code_of_conduct.md +74 -0
  72. data/docs-src/docs/development/contributing.md +49 -0
  73. data/docs-src/docs/development/license.md +10 -0
  74. data/docs-src/docs/imported/changelog.md +31 -0
  75. data/docs-src/docs/imported/quick_reference.md +150 -0
  76. data/docs-src/docs/index.md +38 -0
  77. data/docs-src/docs/tutorial/10-getting_started.md +41 -0
  78. data/docs-src/docs/tutorial/20-project_layout.md +115 -0
  79. data/docs-src/docs/tutorial/30-your_first_command.md +126 -0
  80. data/docs-src/docs/tutorial/40-options_parameters_and_arguments.md +251 -0
  81. data/docs-src/docs/tutorial/50-publishing.md +47 -0
  82. data/docs-src/docs/whoami.md +28 -0
  83. data/docs-src/makesite.sh +14 -0
  84. data/docs-src/mkdocs.yml +76 -0
  85. data/docs-src/runsite.sh +3 -0
  86. data/exe/rbcli +76 -5
  87. data/lib/rbcli/autoupdate/autoupdate.rb +24 -4
  88. data/lib/rbcli/autoupdate/gem_updater.rb +23 -2
  89. data/lib/rbcli/autoupdate/github_updater.rb +22 -1
  90. data/lib/rbcli/configuration/config.rb +22 -1
  91. data/lib/rbcli/configuration/configurate.rb +24 -2
  92. data/lib/rbcli/engine/command.rb +26 -6
  93. data/lib/rbcli/engine/load_project.rb +29 -3
  94. data/lib/rbcli/engine/parser.rb +25 -4
  95. data/lib/rbcli/logging/logging.rb +21 -0
  96. data/lib/rbcli/scriptwrapping/scriptwrapper.rb +30 -11
  97. data/lib/rbcli/stateful_systems/configuratestorage.rb +20 -0
  98. data/lib/rbcli/stateful_systems/state_storage.rb +20 -0
  99. data/lib/rbcli/stateful_systems/storagetypes/localstate.rb +20 -0
  100. data/lib/rbcli/stateful_systems/storagetypes/remote_state_connectors/dynamodb.rb +20 -0
  101. data/lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb +20 -0
  102. data/lib/rbcli/util/hash_deep_symbolize.rb +43 -22
  103. data/lib/rbcli/util/string_colorize.rb +20 -0
  104. data/lib/rbcli/version.rb +21 -1
  105. data/lib/rbcli-tool/generators.rb +20 -0
  106. data/lib/rbcli-tool/mdless_fix.rb +20 -0
  107. data/lib/rbcli-tool/project.rb +27 -2
  108. data/lib/rbcli-tool/util.rb +20 -0
  109. data/lib/rbcli-tool.rb +20 -0
  110. data/lib/rbcli.rb +20 -0
  111. data/lib-sh/lib-rbcli.sh +19 -0
  112. data/rbcli.gemspec +22 -3
  113. data/skeletons/project/CODE_OF_CONDUCT.md +1 -1
  114. data/skeletons/project/README.md +17 -2
  115. data/skeletons/project/application/commands/command.erb +10 -8
  116. data/skeletons/project/application/commands/script.erb +3 -1
  117. data/skeletons/project/application/commands/scripts/script.sh +2 -2
  118. data/skeletons/project/application/options.rb +12 -3
  119. data/skeletons/project/config/autoupdate.rb +5 -2
  120. data/skeletons/project/config/storage.rb +7 -6
  121. data/skeletons/project/config/userspace.rb +6 -1
  122. data/skeletons/project/exe/executable +1 -1
  123. data/skeletons/project/lib/.keep +0 -0
  124. data/skeletons/project/untitled.gemspec +4 -4
  125. data/skeletons/project/{default_user_configs → userconf}/user_defaults.yml +0 -0
  126. metadata +85 -9
  127. data/examples/defaults.yml +0 -4
  128. data/examples/myscript.sh +0 -23
  129. 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 -g option to generate it."
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
 
@@ -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 &block; @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 "#{File.dirname(caller[0].split(':')[0])}/../"
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}/default_user_configs"
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
@@ -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', :type => :boolean, :default => false if data[:allow_json]
31
- opt :config_file, 'Specify a config file manually', :type => :string, :default => data[:config_userfile] unless data[:config_userfile].nil?
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
- path = @path
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
- def deep_symbolize! hsh = nil
6
- hsh ||= self
7
- hsh.keys.each do |k|
8
- if k.is_a? String
9
- hsh[k.to_sym] = hsh[k]
10
- hsh.delete k
11
- end
12
- deep_symbolize! hsh[k.to_sym] if hsh[k.to_sym].is_a? Hash
13
- end
14
- hsh
15
- end
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
- def deep_stringify! hsh = nil
18
- hsh ||= self
19
- hsh.keys.each do |k|
20
- if k.is_a? Symbol
21
- hsh[k.to_s] = hsh[k]
22
- hsh.delete k
23
- end
24
- deep_stringify! hsh[k.to_s] if hsh[k.to_s].is_a? Hash
25
- end
26
- hsh
27
- end
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
- VERSION = "0.1.10"
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)