

GitHub - alejandrogallo/rooki: A stupid simple script runner supporting c, c++,...
source link: https://github.com/alejandrogallo/rooki
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

rooki
A stupid simple script runner supporting c, c++, rust, haskell and virtually anything
Rooki
is written in 20 lines of bash
, and has a very flexible
functionality.
How does it work?
You just write comments as rooki
instructions, the only instruction that
you have to define is the rooki:spell
, which will be run in the shell.
Otherwise you can define any flag you want with the name you want for instance
in a c
file, the following
// rooki:someflag -I$(pwd) // rooki:someflag -I$HOME
will define a shell variable someflag
with the value
someflag="-I$(pwd) -I$HOME"
which later can be used in the rooki:spell
section as
// rooki:someflag -I$(pwd) // rooki:someflag -I$HOME // rooki:spell cc $someflag $f -o $bin
There are some general variables already defined:
Variable | Explanation | Example |
---|---|---|
bin |
Path to the created binary | rooki:spell gcc $f -o $bin |
f |
Path to the temporary source file that will be compiled | // rooki:spell gcc $f -o $bin |
src |
Path to the source file, the caller | rooki:include -I$(dirname $src)/include |
config_folder |
Path to rooki config folder |
What rooki
does when you do rooki yourscript
is the following
- Create a temporal file and save the path in the variable
f
. - Create a
bin
path out of themd5
hash of the source script, the bin will be stored in$XDG_CONFIG_HOME/rooki/
. In the case that yourXDG_CONFIG_HOME
is not defined, it will be stored in~/.config/rooki/
. - Remove the shbang (
#!/usr/bin/env rooki
) on top of your script (if there is any) and copy the script to$f
without the shbang. - Read the
rooki:
flags stored in text in your script. - Expand shell constructs within these flags, environment variables and general shell commands within.
- Run the
rooki:spell
construct, which should be creating a binary in the path$bin
.
Quick start
For instance to write a c++
script called hello.cxx
just create an executable file hello.cxx
and write
#!/usr/bin/env rooki // rooki:flags -pedantic -std=c++11 // rooki:flags -x c++ // rooki:include -I/usr/include // rooki:include -I$HOME/.local/include // rooki:spell g++ $flags $include $f -o $bin #include <iostream> int main(int argc, char *argv[]) { std::cout << "Hello world" << std::endl; return 0; }
then do
./test.cxx
# or
rooki test.cxx
if you want to see exactly what rooki is doing then set the environment variable
ROOKI_DEBUG
like this
ROOKI_DEBUG=1 ./test.cxx
Recommend
-
238
前端小密圈 博客签名:若批评无自由,则赞美无意义。 博客目的:风起于青萍之末,浪成于微澜之间。
-
143
Glorytun Glorytun is a small, simple and secure multipath UDP tunnel. Please use the stable branch. Visit the
-
70
Papis
-
55
a super simple stupid event-loop kernel in pure PHP
-
134
README.md Easy Rules The simple, stupid rules engine for Java™
-
10
A Case Study in Vim Script 101: Making a Test Runner "Hello there, what's this?" you ask. It's a case study in how one might use Vim script, a programming language built in to Vim. We'll walk through th...
-
9
use-change The one "keep it stupid simple" React hook for application state Define a skeleton of...
-
5
just-tap A simple tap test runner that can be used in any client/server javascript app. Installation npm install --save-dev just-tap Usage import createTestSuite from 'j...
-
5
Template (TP) CLI A stupid simple way to generate and share template files locally and with your team. Think in this CLI like @angular/schematics but way more simpler to configure and use. If you work on...
-
12
Stupid simple script copied and pasted from reg.py/lookupsid and inspired from itm4n's session enum via registry · GitHub ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK