Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jinreal committed Mar 26, 2024
0 parents commit 3d97500
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## [0.0.1] - 2024-03-26

### Added

- Run single file/source using the same command.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Jin Real

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
61 changes: 61 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
A runtime utility that simplify basic operations of language runtimes in linux.

# Language Runtime Support
|language/runtime|comment|
|-|-|
|gcc||
|g++||
|go||
|nodejs||
|python||

# Install
1. Download:
```
wget https://raw.githubusercontent.com/jinreal/rtutil/main/rt
```
2. Make `rt` executable:
```
chmod +x rt
```
3. Copy `rt` to binary directory(e.g. `/usr/local/bin`):
```
cp rt BINARY_DIRECTORY
```

# Usage
Run a c file:
```
rt main.c
```

Run a c++ file:
```
rt main.cc
```

Run a go file (project must be initialized using `go mod init`):
```
rt main.go
```

Run a node.js file:
```
rt main.js
```

Run a python file:
```
rt main.py
```

# Test Language Runtime & System
|language/runtime|version|
|-|-|
|gcc|12.2.0|
|g++|12.2.0|
|go|1.19.8|
|nodejs|20.11.1|
|python|3.11.2|

__system__: MX 23.2 (Debian GNU/Linux 12, kernel=6.1.0-17-amd64)
40 changes: 40 additions & 0 deletions rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
bin="echo"
params=("\"Invalid command.\"")
epilogue=()

if [[ "$1" == *.c ]]; then
bin="gcc"
params=("$1")
epilogue=("./a.out")
elif [[ "$1" == *.cc ]]; then
bin="g++"
params=("$1")
epilogue=("./a.out")
elif [[ "$1" == *.go ]]; then
bin="go"
params=("run" "$1")
elif [[ "$1" == *.js ]]; then
bin="node"
params=("$1")
elif [[ "$1" == *.py ]]; then
bin="python"
params=("$1")
fi

# run command
mainCmd="$bin"
for el in "${params[@]}"; do
mainCmd+=" $el"
done
eval "$mainCmd"

if [ ${#epilogue[@]} -eq 0 ]; then
exit
fi

# run epilogue
epilogueCmd=""
for el in "${epilogue[@]}"; do
epilogueCmd+="$el "
done
eval "$epilogueCmd"

0 comments on commit 3d97500

Please sign in to comment.