diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100755 index 0000000..68481d5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## [0.0.1] - 2024-03-26 + +### Added + +- Run single file/source using the same command. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d39ce72 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/Readme.md b/Readme.md new file mode 100755 index 0000000..59d69c0 --- /dev/null +++ b/Readme.md @@ -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) \ No newline at end of file diff --git a/rt b/rt new file mode 100755 index 0000000..3a670ae --- /dev/null +++ b/rt @@ -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" \ No newline at end of file