sysll 0.1.1 → 1.0.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.
- checksums.yaml +4 -4
- data/lib/cmd.rb +86 -52
- data/lib/sysll.rb +31 -0
- data/locales/en.yml +38 -0
- data/locales/pt.yml +38 -0
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af7f45e57a06765cbf24b19fdbda0a84d437be57afb1f48e9c95c3cacc2e7488
|
4
|
+
data.tar.gz: d2157dc4715b644e2b26d64e7ecfe391b5967702dfa7f3ea108aa4a79093d918
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e8dd751d77543270de1d58b5a33693b63262e958b8477a2a0f43587e5e7e6f7252eab0b8a48863c8bd92bbc5dd231dc6aa084a5eb6737498574f289cdd4831
|
7
|
+
data.tar.gz: ee80531120dcc66d840cd7a6471b0aafd6d7474a2bd25962b34fed411ff9b4bf1438efcfca44bf05ea6ab2e40ed4bdc748a27b52782911ac68b1822dedd79e37
|
data/lib/cmd.rb
CHANGED
@@ -1,75 +1,109 @@
|
|
1
1
|
require_relative 'sysverify'
|
2
2
|
|
3
3
|
module CMD
|
4
|
+
module Utils
|
5
|
+
def execute_command(command, error_key, args = {})
|
6
|
+
success = system(command)
|
7
|
+
unless success
|
8
|
+
error = I18n.t("errors.#{error_key}", **args)
|
9
|
+
print_error(error)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def print_error(error)
|
14
|
+
puts "Error Code: #{error[:code]}"
|
15
|
+
puts "Error Type: #{error[:type]}"
|
16
|
+
puts "Message: #{error[:message]}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
4
20
|
class CALL
|
21
|
+
extend CMD::Utils
|
5
22
|
def self.clear
|
6
|
-
|
7
|
-
|
8
|
-
system('cls')
|
9
|
-
else
|
10
|
-
system('clear')
|
11
|
-
end
|
23
|
+
cmd_clear = SYSll::VERIFY.os == :windows ? 'cls' : 'clear'
|
24
|
+
execute_command(cmd_clear, "clear_failed")
|
12
25
|
end
|
13
26
|
|
14
27
|
def self.list_files(flags = nil)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
else
|
22
|
-
system("ls #{flags}")
|
23
|
-
end
|
24
|
-
end
|
28
|
+
cmd_lf = if SYSll::VERIFY.os == :windows
|
29
|
+
'dir'
|
30
|
+
else
|
31
|
+
flags.nil? ? "ls" : "ls #{flags}"
|
32
|
+
end
|
33
|
+
execute_command(cmd_lf, "list_files_failed")
|
25
34
|
end
|
26
35
|
|
27
36
|
def self.network_info
|
28
|
-
|
29
|
-
|
30
|
-
system('ipconfig')
|
31
|
-
else
|
32
|
-
system('ifconfig')
|
33
|
-
end
|
37
|
+
cmd_netinf = SYSll::VERIFY.os == :windows ? 'ipconfig' : 'ifconfig'
|
38
|
+
execute_command(cmd_netinf, "network_info_failed")
|
34
39
|
end
|
35
40
|
|
36
41
|
def self.process_info
|
37
|
-
|
38
|
-
|
39
|
-
system("tasklist")
|
40
|
-
else
|
41
|
-
system("ps aux")
|
42
|
-
end
|
42
|
+
cmd_process = SYSll::VERIFY.os == :windows ? 'tasklist' : 'ps aux'
|
43
|
+
execute_command(cmd_process, "process_info_failed")
|
43
44
|
end
|
44
45
|
|
45
46
|
def self.kill_process(pid, flag = nil)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
else
|
54
|
-
if flags.nil?
|
55
|
-
system("kill #{pid}")
|
56
|
-
else
|
57
|
-
system("kill #{flag} #{pid}")
|
58
|
-
end
|
59
|
-
end
|
47
|
+
cmd_kill = if SYSll::VERIFY.os == :windows
|
48
|
+
flag.nil? ? "taskkill /PID #{pid}" : "taskkill /PID #{pid} #{flag}"
|
49
|
+
else
|
50
|
+
flag.nil? ? "kill #{pid}" : "kill #{flag} #{pid}"
|
51
|
+
end
|
52
|
+
execute_command(cmd_kill, "kill_process_failed", pid: pid)
|
60
53
|
end
|
61
54
|
|
62
55
|
def self.sys(flags = nil)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
56
|
+
cmd_sys = SYSll::VERIFY.os == :windows ? "systeminfo" : flags.nil? ? "uname" : "uname #{flags}"
|
57
|
+
execute_command(cmd_sys, "sys_failed")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class KERNEL
|
62
|
+
extend CMD::Utils
|
63
|
+
DELIMITERS = ["\n"]
|
64
|
+
REGSPLIT = Regexp.union(DELIMITERS)
|
65
|
+
def self.clear
|
66
|
+
krn_clear = SYSll::VERIFY.os == :windows ? Kernel.`("cls") : Kernel.`("clear")
|
67
|
+
return krn_clear
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.list_files(flags = nil)
|
71
|
+
krn_lf = SYSll::VERIFY.os == :windows ? Kernel.`("dir").split(REGSPLIT) : flags.nil? ? Kernel.`("ls").split(REGSPLIT) : Kernel.`("ls #{flags}").split(REGSPLIT)
|
72
|
+
return krn_lf
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.network_info
|
76
|
+
krn_netinf = SYSll::VERIFY.os == :windows ? Kernel.`("ipconfig").split(REGSPLIT) : Kernel.`("ifconfig").split(REGSPLIT)
|
77
|
+
return krn_netinf
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.process_info
|
81
|
+
krn_process = SYSll::VERIFY.os == :windows ? Kernel.`("tasklist") : Kernel.`("ps aux").split(REGSPLIT)
|
82
|
+
return krn_process
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.kill_process(pid, flag = nil)
|
86
|
+
krn_kill = if SYSll::VERIFY.os == :windows
|
87
|
+
flags.nil? ? Kernel.`("taskill /PID #{pid}").split(REGSPLIT) : Kernel.`("taskill /PID #{pid} #{flag}").split(REGSPLIT)
|
88
|
+
else
|
89
|
+
flags.nil? ? Kernel.`("kill #{pid}").split(REGSPLIT) : Kernel.`("kill #{flag} #{pid}").split(REGSPLIT)
|
90
|
+
end
|
91
|
+
return krn_kill
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.sys(flags = nil)
|
95
|
+
krn_sys = if SYSll::VERIFY.os == :windows
|
96
|
+
Kernel.`("systeminfo")
|
97
|
+
else
|
98
|
+
if flags.nil?
|
99
|
+
Kernel.`("uname").split(REGSPLIT)
|
100
|
+
else
|
101
|
+
uname_delimiters = ["\n", " "]
|
102
|
+
reguname = Regexp.union(uname_delimiters)
|
103
|
+
return Kernel.`("uname #{flags}").split(reguname)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
return krn_sys
|
73
107
|
end
|
74
108
|
end
|
75
109
|
end
|
data/lib/sysll.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
require_relative 'sysverify'
|
2
2
|
require_relative 'cmd'
|
3
|
+
require 'i18n'
|
4
|
+
|
5
|
+
local_path = File.expand_path("../../locales/*.yml", __FILE__)
|
6
|
+
I18n.load_path += Dir[local_path]
|
7
|
+
I18n.default_locale = :en
|
3
8
|
|
4
9
|
module SYSll
|
5
10
|
class CALL
|
@@ -27,4 +32,30 @@ module SYSll
|
|
27
32
|
CMD::CALL.sys(flags)
|
28
33
|
end
|
29
34
|
end
|
35
|
+
|
36
|
+
class KERNEL
|
37
|
+
def self.clear
|
38
|
+
CMD::KERNEL.clear
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.list_files(flags = nil)
|
42
|
+
CMD::KERNEL.list_files(flags)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.network_info
|
46
|
+
CMD::KERNEL.network_info
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.process_info
|
50
|
+
CMD::KERNEL.process_info
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.kill_process(pid, flag = nil)
|
54
|
+
CMD::KERNEL.kill_process(pid, flag)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.sys(flags = nil)
|
58
|
+
CMD::KERNEL.sys(flags)
|
59
|
+
end
|
60
|
+
end
|
30
61
|
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
en:
|
2
|
+
sysll:
|
3
|
+
status:
|
4
|
+
clear: "Cleared the screen successfully."
|
5
|
+
list_files: "Listing files in the current directory..."
|
6
|
+
network_info: "Fetching network configuration..."
|
7
|
+
process_info: "Retrieving running processes..."
|
8
|
+
kill_process: "Trying to kill process %{pid}..."
|
9
|
+
sys: "Getting system information..."
|
10
|
+
errors:
|
11
|
+
list_files_failed:
|
12
|
+
code: "SYSLL - E001"
|
13
|
+
message: "Failed to list files. Check permissions or flags."
|
14
|
+
type: "PermissionError"
|
15
|
+
network_info_failed:
|
16
|
+
code: "SYSLL - E002"
|
17
|
+
message: "Could not retrieve network info."
|
18
|
+
type: "NetworkError"
|
19
|
+
process_info_failed:
|
20
|
+
code: "SYSLL - E003"
|
21
|
+
message: "Error retrieving process information."
|
22
|
+
type: "ProcessError"
|
23
|
+
kill_process_failed:
|
24
|
+
code: "SYSLL - E004"
|
25
|
+
message: "Could not kill process %{pid}."
|
26
|
+
type: "ProcessError"
|
27
|
+
sys_failed:
|
28
|
+
code: "SYSLL - E005"
|
29
|
+
message: "Could not retrieve system information."
|
30
|
+
type: "SystemError"
|
31
|
+
clear_failed:
|
32
|
+
code: "SYSLL - E006"
|
33
|
+
message: "Failed to clear the terminal screen."
|
34
|
+
type: "SystemCommandError"
|
35
|
+
unknown_error:
|
36
|
+
code: "SYSLL - E999"
|
37
|
+
message: "An unknown error occurred."
|
38
|
+
type: "UnknownError"
|
data/locales/pt.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
pt:
|
2
|
+
sysll:
|
3
|
+
status:
|
4
|
+
clear: "Tela limpa com sucesso."
|
5
|
+
list_files: "Listando arquivos no diretório atual..."
|
6
|
+
network_info: "Obtendo informações da rede..."
|
7
|
+
process_info: "Recuperando processos em execução..."
|
8
|
+
kill_process: "Tentando encerrar o processo %{pid}..."
|
9
|
+
sys: "Obtendo informações do sistema..."
|
10
|
+
errors:
|
11
|
+
list_files_failed:
|
12
|
+
code: "SYSLL - E001"
|
13
|
+
message: "Falha ao listar os arquivos. Verifique permissões ou flags."
|
14
|
+
type: "ErroDePermissao"
|
15
|
+
network_info_failed:
|
16
|
+
code: "SYSLL - E002"
|
17
|
+
message: "Não foi possível obter informações da rede."
|
18
|
+
type: "ErroDeRede"
|
19
|
+
process_info_failed:
|
20
|
+
code: "SYSLL - E003"
|
21
|
+
message: "Erro ao recuperar informações dos processos."
|
22
|
+
type: "ErroDeProcesso"
|
23
|
+
kill_process_failed:
|
24
|
+
code: "SYSLL - E004"
|
25
|
+
message: "Não foi possível encerrar o processo %{pid}."
|
26
|
+
type: "ErroDeProcesso"
|
27
|
+
sys_failed:
|
28
|
+
code: "SYSLL - E005"
|
29
|
+
message: "Não foi possível obter informações do sistema."
|
30
|
+
type: "ErroDeSistema"
|
31
|
+
clear_failed:
|
32
|
+
code: "SYSLL - E006"
|
33
|
+
message: "Falha ao limpar a tela do terminal."
|
34
|
+
type: "ErroDeComandoDoSistema"
|
35
|
+
unknown_error:
|
36
|
+
code: "SYSLL - E999"
|
37
|
+
message: "Ocorreu um erro desconhecido."
|
38
|
+
type: "ErroDesconhecido"
|
metadata
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sysll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- mvghasty
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
11
|
-
dependencies:
|
10
|
+
date: 2025-04-12 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: i18n
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.12'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '1.12'
|
12
26
|
description: Build your code for multiple platforms easily with the sysll gem
|
13
27
|
email: fasmagoric.dev@gmail.com
|
14
28
|
executables: []
|
@@ -18,13 +32,15 @@ files:
|
|
18
32
|
- lib/cmd.rb
|
19
33
|
- lib/sysll.rb
|
20
34
|
- lib/sysverify.rb
|
21
|
-
|
35
|
+
- locales/en.yml
|
36
|
+
- locales/pt.yml
|
37
|
+
homepage: https://github.com/mvghasty/SYSll
|
22
38
|
licenses:
|
23
39
|
- MIT
|
24
40
|
metadata:
|
25
|
-
homepage_uri: https://github.com/
|
26
|
-
source_code_uri: https://github.com/
|
27
|
-
bug_tracker_uri: https://github.com/
|
41
|
+
homepage_uri: https://github.com/mvghasty/SYSll
|
42
|
+
source_code_uri: https://github.com/mvghasty/SYSll
|
43
|
+
bug_tracker_uri: https://github.com/mvghasty/SYSll/issues
|
28
44
|
rdoc_options: []
|
29
45
|
require_paths:
|
30
46
|
- lib
|