sshman 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38a7a2d296183267a41c7ad685e108cd2c57623e97ed343e61cd74beeb3c1f44
4
- data.tar.gz: e145ddfa534871e8d7d19641f045302cd4b8011407fe2c8c304509dd1827313c
3
+ metadata.gz: 247fe150bd53e1caf0e599d074cce532df14da4c2055af26a94de4baf74e9cc1
4
+ data.tar.gz: 3889aac5b2b664ff32146a625a48fbca2d702b8e8163c20f99ff0c367753d9f4
5
5
  SHA512:
6
- metadata.gz: 0f3b7c7dc52c2acedd868abdb22b3c5fe2328d32c76acf7451849b03885ab8fa564fc794f31988c45e519c4f552e827ea2d1b83eaafb1127c0c94d306f64ade8
7
- data.tar.gz: '0887e63543c07ccb83ec4fc30c0299b38cc81104e316230efab4944ae34f3f022bf76683d8bc4fb6984995bf7959aac92fbbcc3278a9ed6d0b39cec8631731dd'
6
+ metadata.gz: 470ebb35db7788190c13a9f5cd4c78c454a43fdbd9333899e6efe5c1ea40263e16277911af3498772790bea5ad273ec2d6334e2d167dd2188a8ddb47a804c4f2
7
+ data.tar.gz: b1a23ef51b01000ca5642b04c2d22910d7c03dd2d29b13aef9cd4678acd348a479b74862249560888da4068085ae48224938d019622b7ec3e9ab2663c53f6bc1
data/lib/sshman/sshman.rb CHANGED
@@ -1,10 +1,19 @@
1
- # lib/sshman/sshman.rb
2
1
  require 'csv'
3
2
  require 'io/console'
3
+ require 'logger'
4
4
  require_relative 'version'
5
5
 
6
6
  module Sshman
7
+ RESET_COLOR = "\033[0m"
8
+ RED = "\033[31m"
9
+ GREEN = "\033[32m"
10
+ YELLOW = "\033[33m"
11
+ CYAN = "\033[36m"
12
+ SERVERS_CSV = File.expand_path("~/.sshman_servers.csv")
13
+
7
14
  class CLI
15
+ LOGGER = Logger.new(File.expand_path('~/.sshman.log'))
16
+
8
17
  # This method handles inline commands
9
18
  def self.start(argv)
10
19
  case argv[0]
@@ -28,7 +37,6 @@ module Sshman
28
37
  end
29
38
 
30
39
  # Display the current version
31
-
32
40
  def version
33
41
  puts "sshman version #{Sshman::VERSION}"
34
42
  end
@@ -107,7 +115,7 @@ HELP
107
115
  puts "%-15s %-25s %-6s %-15s %-30s" % [row['alias'], row['hostname'], row['port'], row['username'], row['ssh_key']]
108
116
  end
109
117
  end
110
-
118
+
111
119
  # Add a new server to the CSV file
112
120
  def add_server
113
121
  puts "#{CYAN}Adding a new server...#{RESET_COLOR}"
@@ -194,8 +202,8 @@ HELP
194
202
  def connect_to_server(alias_name = nil)
195
203
  # If no alias is provided, ask the user for one
196
204
  if alias_name.nil?
197
- print "Enter alias of the server to connect: "
198
- alias_name = gets.chomp.strip
205
+ print "Enter alias of the server to connect: "
206
+ alias_name = gets.chomp.strip
199
207
  end
200
208
 
201
209
  # Search for the server in the CSV file
@@ -208,6 +216,7 @@ HELP
208
216
  end
209
217
 
210
218
  unless server
219
+ LOGGER.error("Failed connection attempt to #{alias_name}: No server found")
211
220
  puts "#{RED}No server found with alias '#{alias_name}'.#{RESET_COLOR}"
212
221
  return
213
222
  end
@@ -215,16 +224,14 @@ HELP
215
224
  ssh_command = "ssh #{server['username']}@#{server['hostname']} -p #{server['port']}"
216
225
  ssh_command += " -i #{server['ssh_key']}" unless server['ssh_key'].to_s.empty?
217
226
 
218
- puts "#{CYAN}Connecting to #{alias_name}...#{RESET_COLOR}"
219
- exec ssh_command
227
+ LOGGER.info("Connecting to #{alias_name}...")
228
+
229
+ # Use system to log successful connection
230
+ if system(ssh_command)
231
+ LOGGER.info("Successfully connected to #{alias_name}")
232
+ else
233
+ LOGGER.error("Failed to connect to #{alias_name}")
234
+ end
220
235
  end
221
-
222
- # Constants for coloring terminal output
223
- RESET_COLOR = "\033[0m"
224
- RED = "\033[31m"
225
- GREEN = "\033[32m"
226
- YELLOW = "\033[33m"
227
- CYAN = "\033[36m"
228
- SERVERS_CSV = File.expand_path("~/.sshman_servers.csv")
229
236
  end
230
237
  end
@@ -1,5 +1,5 @@
1
1
  # lib/sshman/version.rb
2
2
 
3
3
  module Sshman
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - SubnetMasked
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-03 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple terminal-based SSH manager to add, list, delete, and connect
14
14
  to SSH servers.