Skip to content
/ SYSll Public

SYSll is a Ruby gem designed to provide a unified interface for executing common system commands across multiple operating systems. It automatically detects the user's OS and runs the appropriate command, offering a seamless experience for Windows, Linux, macOS, and Unix-based systems.

License

Notifications You must be signed in to change notification settings

mvghasty/SYSll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYSll - Cross-Platform System Commands for Ruby

Licence Ruby


SYSll-removebg-preview

SYSll is a robust Ruby gem offering a unified interface for executing low-level system commands across different operating systems, including Linux, macOS, Windows, Unix-based systems and Android. It intelligently adapts commands based on the user’s OS, providing seamless cross-platform compatibility.


FEATURES

  • Cross-platform Command Abstraction: Dynamically handles OS-specific commands for consistent behavior.

  • Adaptive OS Detection: Automatically detects the operating system and selects appropriate syscalls.

  • Extensible API Surface: Exposes a concise yet powerful API for system interactions.

  • Graceful Error Handling: Implements fail-safes for invalid commands or restricted permissions.


INSTALLATION

Add this line to your Gemfile:

# Using Bundler
gem 'sysll', git: 'https://github.com/fasmagoric/SYSll'

Or install it with gem:

gem install sysll

ARCHITECTURE

The architecture is modular and static, designed for reusability and maintainability.

Module: SYSll

This is the gem’s entry point. It exposes two main classes:

  • SYSll::CALL = Executes system commands using system, with direct terminal output

  • SYSll::KERNEL = Return the commands using cmd, communicating directly with the kernel and returning the output in an array or a string parsed and formated.


USAGE

SYSll::CALL usages

require 'sysll'

# Clear terminal
SYSll::CALL.clear

# List files (with optional flags on Unix systems)
SYSll::CALL.list_files
SYSll::CALL.list_files('-la')

# Show network info
SYSll::CALL.network_info

# Show process info
SYSll::CALL.process_info

# Kill a process by PID (with flags)
SYSll::CALL.kill_process(1234)
SYSll::CALL.kill_process(1234, '/F') # For WINDOWS systems
SYSll::CALL.kill_process(1234, '-9') # For UNIX systems

# System information (with opitional flags on Unix systems)
SYSll::CALL.sys
SYSll::CALL.sys('-a')

SYSll::KERNEL usages

require 'sysll'

clear = SYSll::KERNEL.clear
print clear
# OUTPUT: ["\e[H\e[2J\e[3J"]

list_files = SYSll::KERNEL.list_files
list_files_flag = SYSll::KERNEL.list_files('-la')
my_folder = SYSll::KERNEL.list_files('-a')[4]

print "Thats the list of files:\n"
print list_files
print "\n\nThats my test folder:\n"
print my_folder
print "\n\nThats the list of files with the flag '-la':\n"
print list_files_flag
# OUTPUT:
# Thats the list of files:
# ["Gemfile", "Gemfile.lock", "test_folder", "test.rb"]
#
# Thats my test folder:
# test_folder
#
# Thats the list of files with the flag '-la':
# ["total 12", "drwxr-xr-x. 1 mavic mavic  74 abr 13 11:48 .", "drwxr-xr-x. 1 mavic mavic 378 abr 13 05:54 ..", "-rw-r--r--. 1 mavic m
# avic  43 abr 12 05:17 Gemfile", "-rw-r--r--. 1 mavic mavic 239 abr 13 11:33 Gemfile.lock", "drwxr-xr-x. 1 mavic mavic   0 abr 13 11:
# 36 test_folder", "-rw-r--r--. 1 mavic mavic 337 abr 13 11:48 test.rb"]⏎                                                             
 
my_os = SYSll::KERNEL.sys('-a')[0..1]
print my_os
# OUTPUT:
# ["Linux", "fedora"]

DEVEL

Clone the repository and install dependencies:

git clone https://github.com/fasmagoric/SYSll.git
cd SYSll
bundle install

and to build and push:

gem build sysll.gemspec
gem push sysll-0.1.0.gem

CONTRIBUTING

Feel free to fork, create issues, and submit pull requests. Contributions are welcome!

About

SYSll is a Ruby gem designed to provide a unified interface for executing common system commands across multiple operating systems. It automatically detects the user's OS and runs the appropriate command, offering a seamless experience for Windows, Linux, macOS, and Unix-based systems.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published