JCLI combines the familiarity of traditional shell commands with robust Java architecture, comprehensive testing, and cross-platform compatibility.
JCLI is a comprehensive CLI shell implementation that recreates essential Unix/Linux commands in pure Java. It features a modular architecture, extensive testing suite, and advanced capabilities like command piping, output redirection, aliases, and persistent configuration.
|
π₯ 20+ Built-in Commands π Command Pipeline Support π€ Output Redirection βοΈ Persistent Configuration |
π Command History π‘οΈ Path Security π Cross-Platform β‘ Native Compilation |
| Command | Syntax | Description |
|---|---|---|
help |
help [command] |
Show all commands or help for specific command |
echo |
echo [args] |
Print arguments to console |
pwd |
pwd |
Print current working directory |
cd |
cd [dir] |
Change directory (default: home) |
ls |
ls [-r -l -a] |
List directory contents with options |
cp |
cp [-r -i] [src] [dest] |
Copy files/directories |
mv |
mv [-i] [src] [dest] |
Move/rename files |
mkdir |
mkdir [dir] |
Create directory |
rmdir |
rmdir [dir] |
Remove empty directory |
rm |
rm [file] |
Remove file |
rm -r |
rm -r [dir] |
Remove directory recursively |
touch |
touch [file] |
Create empty file or update timestamp |
cat |
cat [file] |
Display file contents |
grep |
grep [-i -n] [pattern] [file] |
Search text patterns |
wc |
wc [file] |
Count lines, words, characters |
head |
head [-n N] [file] |
Display first N lines (default: 10) |
tail |
tail [-n N] [file] |
Display last N lines (default: 10) |
sort |
sort [-r] [file] |
Sort lines alphabetically |
find |
find [-name pattern] |
Find files matching pattern |
history |
history [-c -n N] |
Show command history |
clear |
clear |
Clear terminal screen |
date |
date |
Display current date and time |
alias |
alias [name=command] |
Create command aliases |
exit |
exit |
Exit the CLI |
Chain commands together with Unix-style piping:
cat file.txt | grep "pattern" | sort | head -5
find . -name "*.txt" | head -10
ls -l | grep "2024"Redirect command output to files:
echo "Hello World" > output.txt
ls -l > directory_listing.txt
date > timestamp.txtCreate shortcuts for frequently used commands:
alias ll='ls -l'
alias la='ls -a'
alias grep-java='grep -i java'- Config file:
~/.clircstores aliases and prompt settings - Persistent aliases: Automatically loaded on startup
- Custom prompt: Configurable command prompt format
- Persistent storage: History saved to
~/.cli_history - Search capabilities:
history -n 20shows last 20 commands - History clearing:
history -cclears all history
- Language: Java 21 with modern features (records, pattern matching, text blocks)
- Build System: Maven 3.9+ with comprehensive dependency management
- Logging: SLF4J with Logback for structured logging
- Testing: JUnit 5 with extensive unit and integration tests
- Code Coverage: JaCoCo integration for test coverage analysis
- Path Validation: Automatic prevention of directory traversal attacks
- Safe File Operations: All file operations validate paths against working directory
- Input Sanitization: Command arguments are properly validated and escaped
- Cross-Platform: Native support for Windows, Linux, and macOS
- Memory Efficient: Optimized for low memory footprint
- Fast Startup: Sub-second startup time
- Native Compilation: GraalVM support for native executables
| Tool | Version | Verification Command |
|---|---|---|
| JDK 21 | OpenJDK 21+ | java -version |
| Maven | 3.9+ | mvn -version |
| Git | Latest | git --version |
Install VS Code from code.visualstudio.com with these extensions:
- Java Extension Pack - Complete Java development support
- Maven for Java - Maven project management
- GitLens - Enhanced Git capabilities (optional)
- GraalVM 21 - For creating native executables
- Enables ultra-fast startup and reduced memory usage
# Linux (Ubuntu/Debian)
sudo apt install openjdk-21-jdk
# macOS (Homebrew)
brew install openjdk@21
# Windows
# Download from https://adoptium.net/# Linux
sudo apt install maven
# macOS
brew install maven
# Windows
# Download from https://maven.apache.org/download.cgi# Linux
sudo apt install git
# macOS
brew install git
# Windows
# Download from https://git-scm.com/download/win# Clone the repository
git clone https://github.com/MuhammadAliAsgher/JCLI.git
cd JCLI
# Build the project
mvn clean compile
# Run tests
mvn test
# Create executable JAR
mvn package
# Run the application
java -jar target/JCLI-1.0-SNAPSHOT.jar- Open project in VS Code:
code . - Install recommended extensions when prompted
- VS Code will automatically configure Java classpath and build settings
- Compile:
mvn compile - Test:
mvn test - Package:
mvn package - Clean:
mvn clean
# Navigate and explore
pwd
ls -la
cd Documents
mkdir projects
cd projects
# Create and edit files
touch README.md
echo "# My Project" > README.md
cat README.md# Find and filter files
find . -name "*.java" | head -10
ls -l | grep "txt" | sort
# Process file contents
cat logfile.txt | grep "ERROR" | wc
head -20 data.csv | tail -5# Create useful shortcuts
alias ll='ls -l'
alias la='ls -a'
alias projects='cd ~/Documents/projects'
# Use aliases
ll
la
projects# View command history
history
history -n 10
# Clear screen and history
clear
history -cThe project includes comprehensive testing coverage:
# Run all tests
mvn test
# Run specific test class
mvn test -Dtest=ShellIntegrationTest
# Generate coverage report
mvn jacoco:report
# View coverage report
open target/site/jacoco/index.html- Unit Tests: Individual command testing with mocks
- Integration Tests: End-to-end workflow validation
- Security Tests: Path traversal and input validation
- Performance Tests: Memory and execution time validation
Edit ~/.clirc to add persistent aliases:
alias ll='ls -l'
alias la='ls -a'
alias grep-java='grep -i java'
prompt=%s $JCLI_HOME: Override default configuration directoryJCLI_HISTORY_SIZE: Set maximum history entries (default: 1000)
# Install GraalVM native-image
gu install native-image
# Create native executable
native-image -jar target/JCLI-1.0-SNAPSHOT.jar jcli
# Run native executable
./jcliWe welcome contributions! Here's how to get started:
- Fork the repository on GitHub
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes with appropriate tests
- Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request with detailed description
- Follow Java coding standards and conventions
- Add tests for new features and bug fixes
- Update documentation for user-facing changes
- Ensure all tests pass before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Unix/Linux command-line tools
- Built with modern Java 21 features
- Comprehensive testing with JUnit 5
- Maven build system and dependency management







