overmind 0.1.1-arm-linux → 0.1.2-arm-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aed00bb925ee2d4b8a5aae2bd6f52a3719fb902715150aefc81c8b05ffc21e81
4
- data.tar.gz: 276042a7d836b2800654a661250fa1201b69d13648b433d20bf7fd4a6757efdb
3
+ metadata.gz: cd5c5e797e065096658df8481b8417c4e3b2668741d40bd72065269c8e5795dc
4
+ data.tar.gz: 0cc10754c99189642ccad4b0c0c9cff8abdc56431f789f57f6ac5dfd6ef671c3
5
5
  SHA512:
6
- metadata.gz: 01b3bee209758d949468e656d1060992508e8c33a29fb6d1c7742c97790d4caebd25a309e002964d91cd9ecfa599746b9bf1052fa7b953414ed9b9186d95ce1f
7
- data.tar.gz: ae7147b4baaeb61b5a02f2285ccef745020fc787283b17a7f1140a9829fa4e73a3739818bb02bf0e40e716f47018377434b169906229ebdeed07ce316578aa85
6
+ metadata.gz: 62289a80b144e87236d87dfa5f1347f9372fe5c1db0fbe9e0c9e9b824476f7027fe26b7491d5d6fcec9b60dde158e458f3ecaefd99e7ee979c40d84fa9f21d18
7
+ data.tar.gz: 2442dded6ccf1f9a5e58116b5122a8bfb35593d5405a0dfb8bab26b9762c77703e7a4cd8e82ab16f7dd899682a1b930f40e4c9a9bf39fdc811a38399a7b04433
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overmind
4
+ # Command-line interface for running golang library Overmind
5
+ # It ensures that the necessary dependencies, such as tmux, are present
6
+ # and runs Overmind with any provided arguments.
7
+ class CLI
8
+ SUPPORTED_OS_REGEX = /darwin|linux|bsd/i
9
+ # Path to the library's executable files
10
+ LIBRARY_PATH = File.expand_path("#{File.dirname(__FILE__)}/../../libexec")
11
+ OVERMIND_PATH = "#{LIBRARY_PATH}/overmind"
12
+ TMUX_FOLDER_PATH = "#{LIBRARY_PATH}/prebuilt-tmux/bin"
13
+ TMUX_PATH = "#{TMUX_FOLDER_PATH}/tmux"
14
+
15
+ def run(args = [])
16
+ os_validate!
17
+ validate_tmux_present!
18
+ validate_overmind_present!
19
+
20
+ # Ensures arguments are properly quoted if they contain spaces
21
+ args = args.map { |x| x.include?(" ") ? "'#{x}'" : x }
22
+
23
+ # Use prebuild tmux if found
24
+ path_with_tmux = File.exist?(TMUX_PATH) ? "#{ENV["PATH"]}:#{TMUX_FOLDER_PATH}" : ENV["PATH"]
25
+
26
+ # Spawns the Overmind process with modified PATH if necessary
27
+ pid = spawn({"PATH" => path_with_tmux}, "#{OVERMIND_PATH} #{args.join(" ")}")
28
+
29
+ Process.wait(pid)
30
+
31
+ $?.exitstatus
32
+ end
33
+
34
+ private
35
+
36
+ # Checks if the current OS is supported based on a regex match
37
+ def os_supported?
38
+ RUBY_PLATFORM.match?(SUPPORTED_OS_REGEX)
39
+ end
40
+
41
+ # Checks if tmux is installed either globally or as a prebuilt binary
42
+ def tmux_installed?
43
+ system("which tmux") || File.exist?(TMUX_PATH)
44
+ end
45
+
46
+ # Checks if the Overmind executable is present
47
+ def overmind_installed?
48
+ File.exist?(OVERMIND_PATH)
49
+ end
50
+
51
+ # Validates the operating system and aborts with an error message if unsupported
52
+ def os_validate!
53
+ return if os_supported?
54
+
55
+ abort_with_message("Error: This gem supports Linux, *BSD, and macOS only.")
56
+ end
57
+
58
+ # Validates the presence of tmux and aborts with an error message if not found
59
+ def validate_tmux_present!
60
+ return if tmux_installed?
61
+
62
+ abort_with_message(<<~MSG)
63
+ Error: tmux not found. Please ensure tmux is installed and available in PATH.
64
+ If tmux is not installed, you can usually install it using your package manager. For example:
65
+
66
+ # For Ubuntu/Debian
67
+ sudo apt-get install tmux
68
+ #{" "}
69
+ # For macOS
70
+ brew install tmux
71
+ #{" "}
72
+ # For FreeBSD
73
+ sudo pkg install tmux
74
+
75
+ Installation commands might vary based on your operating system and its version.#{" "}
76
+ Please consult your system's package management documentation for the most accurate instructions.
77
+ MSG
78
+ end
79
+
80
+ # Validates the presence of Overmind and aborts with an error message if not found
81
+ def validate_overmind_present!
82
+ return if overmind_installed?
83
+
84
+ abort_with_message("Error: Invalid platform. Overmind wasn't built for #{RUBY_PLATFORM}")
85
+ end
86
+
87
+ # Aborts execution with a given error message
88
+ def abort_with_message(message)
89
+ warn "\e[31m#{message}\e[0m"
90
+ exit 1
91
+ end
92
+ end
93
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Overmind
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overmind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - prog-supdex
@@ -63,6 +63,7 @@ files:
63
63
  - LICENSE.txt
64
64
  - bin/overmind
65
65
  - lib/overmind.rb
66
+ - lib/overmind/cli.rb
66
67
  - lib/overmind/version.rb
67
68
  - libexec/overmind
68
69
  - libexec/prebuilt-tmux/bin/tmux