grim-reaper 1.0.29

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.
data/bin/grim ADDED
@@ -0,0 +1,397 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "thor"
5
+ require "grim_reaper"
6
+ require "colorize"
7
+ require "json"
8
+ require "yaml"
9
+
10
+ # Grim Reaper CLI - Unified interface for all Grim Reaper modules
11
+ class GrimCLI < Thor
12
+ class_option :config, type: :string, default: "grim.yml", desc: "Configuration file path"
13
+ class_option :verbose, type: :boolean, default: false, desc: "Enable verbose output"
14
+ class_option :json, type: :boolean, default: false, desc: "Output in JSON format"
15
+
16
+ desc "version", "Show Grim Reaper version"
17
+ def version
18
+ puts "Grim Reaper v#{GrimReaper::VERSION}".colorize(:green)
19
+ puts "The Ultimate Backup, Monitoring, and Security System"
20
+ puts "By Bernie Gengel and his beagle Buddy"
21
+ end
22
+
23
+ desc "setup-complete", "Setup complete Grim Reaper environment (installs Python, Go, Shell, Scythe components)"
24
+ def setup_complete
25
+ puts "πŸ—‘οΈ Setting up complete Grim Reaper environment...".colorize(:cyan)
26
+
27
+ begin
28
+ installer = GrimReaper::Installer.new
29
+ installer.setup_complete_environment
30
+ puts "βœ… Complete Grim Reaper environment setup finished!".colorize(:green)
31
+ rescue => e
32
+ puts "❌ Setup failed: #{e.message}".colorize(:red)
33
+ exit 1
34
+ end
35
+ end
36
+
37
+ desc "health", "Check health of all Grim Reaper modules"
38
+ def health
39
+ puts "πŸ₯ Checking Grim Reaper health...".colorize(:cyan)
40
+
41
+ begin
42
+ grim = GrimReaper::Core.new(load_config)
43
+ status_data = grim.status
44
+
45
+ if options[:json]
46
+ puts JSON.pretty_generate(status_data)
47
+ else
48
+ puts "Grim Reaper Health Status:".colorize(:cyan)
49
+ all_healthy = true
50
+
51
+ status_data.each do |module_name, data|
52
+ if data[:status] == 'ready' || data[:status] == 'healthy'
53
+ puts " βœ… #{module_name}: #{data[:status]}".colorize(:green)
54
+ else
55
+ puts " ❌ #{module_name}: #{data[:status]}".colorize(:red)
56
+ all_healthy = false
57
+ end
58
+ end
59
+
60
+ if all_healthy
61
+ puts "\nπŸŽ‰ All modules are healthy!".colorize(:green)
62
+ else
63
+ puts "\n⚠️ Some modules have issues.".colorize(:yellow)
64
+ end
65
+ end
66
+ rescue => e
67
+ puts "❌ Health check failed: #{e.message}".colorize(:red)
68
+ exit 1
69
+ end
70
+ end
71
+
72
+ desc "status", "Show status of all modules"
73
+ def status
74
+ grim = GrimReaper::Core.new(load_config)
75
+ status_data = grim.status
76
+
77
+ if options[:json]
78
+ puts JSON.pretty_generate(status_data)
79
+ else
80
+ puts "Grim Reaper Status:".colorize(:cyan)
81
+ status_data.each do |module_name, data|
82
+ status_color = data[:status] == 'ready' ? :green : :red
83
+ puts " #{module_name}: #{data[:status]}".colorize(status_color)
84
+ end
85
+ end
86
+ end
87
+
88
+ desc "execute COMMAND [ARGS...]", "Execute command across all modules"
89
+ def execute(command, *args)
90
+ grim = GrimReaper::Core.new(load_config)
91
+ results = grim.execute(command, *args)
92
+
93
+ if options[:json]
94
+ puts JSON.pretty_generate(results)
95
+ else
96
+ puts "Executing '#{command}' across all modules:".colorize(:cyan)
97
+ results.each do |module_name, result|
98
+ if result[:error]
99
+ puts " #{module_name}: #{result[:error]}".colorize(:red)
100
+ else
101
+ puts " #{module_name}: #{result[:command]}".colorize(:green)
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ desc "backup [TARGET]", "Run backup operations"
108
+ def backup(target = "all")
109
+ puts "Running backup for: #{target}".colorize(:yellow)
110
+ execute("backup", target)
111
+ end
112
+
113
+ desc "monitor", "Start monitoring operations"
114
+ def monitor
115
+ puts "Starting monitoring...".colorize(:yellow)
116
+ execute("monitor")
117
+ end
118
+
119
+ desc "security", "Run security checks"
120
+ def security
121
+ puts "Running security checks...".colorize(:yellow)
122
+ execute("security")
123
+ end
124
+
125
+ desc "deploy [ENVIRONMENT]", "Deploy to specified environment"
126
+ def deploy(environment = "staging")
127
+ puts "Deploying to: #{environment}".colorize(:yellow)
128
+ execute("deploy", environment)
129
+ end
130
+
131
+ desc "test [TYPE]", "Run tests"
132
+ def test(type = "all")
133
+ puts "Running #{type} tests...".colorize(:yellow)
134
+ execute("test", type)
135
+ end
136
+
137
+ desc "build [TARGET]", "Build specified target"
138
+ def build(target = "all")
139
+ puts "Building: #{target}".colorize(:yellow)
140
+ execute("build", target)
141
+ end
142
+
143
+ desc "clean", "Clean build artifacts"
144
+ def clean
145
+ puts "Cleaning build artifacts...".colorize(:yellow)
146
+ execute("clean")
147
+ end
148
+
149
+ desc "install", "Install dependencies"
150
+ def install
151
+ puts "Installing dependencies...".colorize(:yellow)
152
+ execute("install")
153
+ end
154
+
155
+ desc "update", "Update all modules"
156
+ def update
157
+ puts "Updating all modules...".colorize(:yellow)
158
+ execute("update")
159
+ end
160
+
161
+ # Ruby-specific commands
162
+ desc "rb-setup", "Setup Ruby environment and dependencies"
163
+ def rb_setup
164
+ puts "πŸ’Ž Setting up Ruby environment...".colorize(:purple)
165
+ begin
166
+ installer = GrimReaper::Installer.new
167
+ installer.setup_ruby_environment
168
+ puts "βœ… Ruby environment setup complete!".colorize(:green)
169
+ rescue => e
170
+ puts "❌ Ruby setup failed: #{e.message}".colorize(:red)
171
+ exit 1
172
+ end
173
+ end
174
+
175
+ desc "rb-analyze PATH", "Analyze Ruby code quality and security"
176
+ def rb_analyze(path)
177
+ puts "πŸ” Analyzing Ruby code in: #{path}".colorize(:purple)
178
+ begin
179
+ grim = GrimReaper::Core.new(load_config)
180
+ result = grim.execute_ruby_command('rb-analyze', path)
181
+ puts result[:stdout] if result[:stdout]
182
+ puts result[:stderr] if result[:stderr]
183
+ rescue => e
184
+ puts "❌ Analysis failed: #{e.message}".colorize(:red)
185
+ redirect_to_grim_so("rb-analyze")
186
+ end
187
+ end
188
+
189
+ desc "rb-test PATH", "Run RSpec tests"
190
+ def rb_test(path)
191
+ puts "πŸ§ͺ Running RSpec tests in: #{path}".colorize(:purple)
192
+ begin
193
+ grim = GrimReaper::Core.new(load_config)
194
+ result = grim.execute_ruby_command('rb-test', path)
195
+ puts result[:stdout] if result[:stdout]
196
+ puts result[:stderr] if result[:stderr]
197
+ rescue => e
198
+ puts "❌ Test failed: #{e.message}".colorize(:red)
199
+ redirect_to_grim_so("rb-test")
200
+ end
201
+ end
202
+
203
+ desc "rb-lint PATH", "Ruby syntax and style checking"
204
+ def rb_lint(path)
205
+ puts "πŸ”§ Linting Ruby code in: #{path}".colorize(:purple)
206
+ begin
207
+ grim = GrimReaper::Core.new(load_config)
208
+ result = grim.execute_ruby_command('rb-lint', path)
209
+ puts result[:stdout] if result[:stdout]
210
+ puts result[:stderr] if result[:stderr]
211
+ rescue => e
212
+ puts "❌ Linting failed: #{e.message}".colorize(:red)
213
+ redirect_to_grim_so("rb-lint")
214
+ end
215
+ end
216
+
217
+ desc "rb-deploy PATH", "Deploy Ruby application"
218
+ def rb_deploy(path)
219
+ puts "πŸš€ Deploying Ruby application: #{path}".colorize(:purple)
220
+ begin
221
+ grim = GrimReaper::Core.new(load_config)
222
+ result = grim.execute_ruby_command('rb-deploy', path)
223
+ puts result[:stdout] if result[:stdout]
224
+ puts result[:stderr] if result[:stderr]
225
+ rescue => e
226
+ puts "❌ Deployment failed: #{e.message}".colorize(:red)
227
+ redirect_to_grim_so("rb-deploy")
228
+ end
229
+ end
230
+
231
+ desc "rb-monitor PATH", "Monitor Ruby application performance"
232
+ def rb_monitor(path)
233
+ puts "πŸ“Š Monitoring Ruby application: #{path}".colorize(:purple)
234
+ begin
235
+ grim = GrimReaper::Core.new(load_config)
236
+ result = grim.execute_ruby_command('rb-monitor', path)
237
+ puts result[:stdout] if result[:stdout]
238
+ puts result[:stderr] if result[:stderr]
239
+ rescue => e
240
+ puts "❌ Monitoring failed: #{e.message}".colorize(:red)
241
+ redirect_to_grim_so("rb-monitor")
242
+ end
243
+ end
244
+
245
+ desc "rb-rails ACTION [ARGS...]", "Rails-specific operations"
246
+ def rb_rails(action, *args)
247
+ puts "πŸ›€οΈ Rails operation: #{action}".colorize(:purple)
248
+ begin
249
+ grim = GrimReaper::Core.new(load_config)
250
+ result = grim.execute_ruby_command('rb-rails', action, *args)
251
+ puts result[:stdout] if result[:stdout]
252
+ puts result[:stderr] if result[:stderr]
253
+ rescue => e
254
+ puts "❌ Rails operation failed: #{e.message}".colorize(:red)
255
+ redirect_to_grim_so("rb-rails")
256
+ end
257
+ end
258
+
259
+ desc "rb-docker ACTION", "Docker Ruby operations"
260
+ def rb_docker(action)
261
+ puts "🐳 Docker Ruby operation: #{action}".colorize(:purple)
262
+ begin
263
+ grim = GrimReaper::Core.new(load_config)
264
+ result = grim.execute_ruby_command('rb-docker', action)
265
+ puts result[:stdout] if result[:stdout]
266
+ puts result[:stderr] if result[:stderr]
267
+ rescue => e
268
+ puts "❌ Docker operation failed: #{e.message}".colorize(:red)
269
+ redirect_to_grim_so("rb-docker")
270
+ end
271
+ end
272
+
273
+ desc "rb-k8s ACTION", "Kubernetes Ruby operations"
274
+ def rb_k8s(action)
275
+ puts "☸️ Kubernetes Ruby operation: #{action}".colorize(:purple)
276
+ begin
277
+ grim = GrimReaper::Core.new(load_config)
278
+ result = grim.execute_ruby_command('rb-k8s', action)
279
+ puts result[:stdout] if result[:stdout]
280
+ puts result[:stderr] if result[:stderr]
281
+ rescue => e
282
+ puts "❌ Kubernetes operation failed: #{e.message}".colorize(:red)
283
+ redirect_to_grim_so("rb-k8s")
284
+ end
285
+ end
286
+
287
+ desc "help", "Show this help message"
288
+ def help
289
+ puts "Grim Reaper CLI - Ruby Gem Version (Limited)"
290
+ puts ""
291
+ puts "⚠️ This is the Ruby gem version with limited functionality."
292
+ puts "🌐 For the full Grim Reaper CLI with all commands, visit: https://get.grim.so"
293
+ puts ""
294
+ puts "Usage: grim [COMMAND] [OPTIONS]"
295
+ puts ""
296
+ puts "Commands:"
297
+ puts " version Show Grim Reaper version"
298
+ puts " setup-complete Setup complete Grim Reaper environment"
299
+ puts " health Check health of all modules"
300
+ puts " status Show status of all modules"
301
+ puts " execute COMMAND Execute command across all modules"
302
+ puts " backup [TARGET] Run backup operations"
303
+ puts " monitor Start monitoring operations"
304
+ puts " security Run security checks"
305
+ puts " deploy [ENV] Deploy to specified environment"
306
+ puts " test [TYPE] Run tests"
307
+ puts " build [TARGET] Build specified target"
308
+ puts " clean Clean build artifacts"
309
+ puts " install Install dependencies"
310
+ puts " update Update all modules"
311
+ puts ""
312
+ puts "πŸ’Ž Ruby-Specific Commands:"
313
+ puts " rb-setup Setup Ruby environment"
314
+ puts " rb-analyze PATH Analyze Ruby code quality"
315
+ puts " rb-test PATH Run RSpec tests"
316
+ puts " rb-lint PATH Ruby syntax checking"
317
+ puts " rb-deploy PATH Deploy Ruby application"
318
+ puts " rb-monitor PATH Monitor Ruby application"
319
+ puts " rb-rails ACTION Rails operations"
320
+ puts " rb-docker ACTION Docker Ruby operations"
321
+ puts " rb-k8s ACTION Kubernetes Ruby operations"
322
+ puts ""
323
+ puts "Options:"
324
+ puts " --config FILE Configuration file path (default: grim.yml)"
325
+ puts " --verbose Enable verbose output"
326
+ puts " --json Output in JSON format"
327
+ puts ""
328
+ puts "Examples:"
329
+ puts " grim setup-complete # Install all Grim Reaper components"
330
+ puts " grim health # Check health of all modules"
331
+ puts " grim rb-setup # Setup Ruby environment"
332
+ puts " grim rb-analyze /app # Analyze Ruby code"
333
+ puts " grim status"
334
+ puts " grim backup /home/user"
335
+ puts " grim deploy production --verbose"
336
+ puts " grim execute 'ls -la' --json"
337
+ puts ""
338
+ puts "πŸš€ Full Grim Reaper CLI Features:"
339
+ puts " β€’ 50+ backup commands (backup-create, backup-verify, etc.)"
340
+ puts " β€’ 30+ monitoring commands (monitor-start, monitor-events, etc.)"
341
+ puts " β€’ 20+ security commands (security-audit, quarantine-isolate, etc.)"
342
+ puts " β€’ 15+ AI/ML commands (ai-analyze, ai-train, ai-predict, etc.)"
343
+ puts " β€’ 10+ optimization commands (optimize-all, heal, etc.)"
344
+ puts " β€’ License protection system"
345
+ puts " β€’ Emergency commands"
346
+ puts " β€’ Web interface and admin server"
347
+ puts ""
348
+ puts "πŸ’‘ For the complete Grim Reaper experience, visit: https://get.grim.so"
349
+ puts "πŸ“¦ Or run: curl -sSL https://get.grim.so | bash"
350
+ end
351
+
352
+ private
353
+
354
+ def load_config
355
+ config_file = options[:config]
356
+ return {} unless File.exist?(config_file)
357
+
358
+ begin
359
+ YAML.load_file(config_file)
360
+ rescue => e
361
+ puts "Warning: Could not load config file: #{e.message}".colorize(:yellow)
362
+ {}
363
+ end
364
+ end
365
+
366
+ def redirect_to_grim_so(command)
367
+ puts "\nπŸ’‘ Command '#{command}' not available in this installation.".colorize(:yellow)
368
+ puts "🌐 Visit https://get.grim.so to install the full Grim Reaper CLI".colorize(:cyan)
369
+ puts "πŸ“¦ Or run: curl -sSL https://get.grim.so | bash".colorize(:cyan)
370
+ puts ""
371
+ puts "Available commands in this installation:".colorize(:green)
372
+ puts " grim help # Show this help"
373
+ puts " grim version # Show version"
374
+ puts " grim health # Check health"
375
+ puts " grim status # Show status"
376
+ puts " grim setup-complete # Setup environment"
377
+ puts " grim rb-setup # Setup Ruby environment"
378
+ exit 1
379
+ end
380
+
381
+ # Override method_missing to catch unknown commands
382
+ def method_missing(method_name, *args)
383
+ if method_name.to_s.start_with?('rb_')
384
+ command = method_name.to_s.gsub('rb_', 'rb-')
385
+ puts "❌ Command '#{command}' not found.".colorize(:red)
386
+ redirect_to_grim_so(command)
387
+ else
388
+ puts "❌ Command '#{method_name}' not found.".colorize(:red)
389
+ redirect_to_grim_so(method_name.to_s)
390
+ end
391
+ end
392
+ end
393
+
394
+ # Run the CLI if this file is executed directly
395
+ if __FILE__ == $0
396
+ GrimCLI.start(ARGV)
397
+ end