Portable and easy Nimscript runner.
With this tool, you can bundle a lot of scripts and run it everywhere
No extra binary needed
First install Nim, then run:
nimble install ezscrAnd the command ezscr will be available in your terminal. (Make sure that
Nimble bin dir is on your PATH)
The usage is very simple and there's just 4 commands that you need to learn!
See some examples here
Run
ezscr new <SCRIPT NAMES...> [-s]-s makes the script secret, and needs to provide the secret (password) that can
be configured at config.yaml (that is created with command new)
Example:
ezscr new helloWorldReturns:
Creating dir /full/path/to/config
Creating file /full/path/to/config/config.yaml
Creating dir /full/path/to/config/secret
Creating script /full/path/to/config/helloWorld.nims
To edit the secret and aliases, just open the config.yaml file.
After you finished the scripting, you need to pack all the scripts into a encrypted JSON (default name is data.enc)
To do that, just run
ezscr packReturns:
Packing /full/path/to/config/helloWorld.nims
Encoding data
To run the script you will need:
- exscr binary
data.encwith script(s) inside
The configs dir you cannot delete because there's no decrypt command.
To run a script just:
ezscr run helloWorldezscr clean_libThanks to the nimscripter lib, the scripts has full support to Nim's std lib
Example working with json
from std/json import parseJson, `{}`, getStr
proc main*(params: seq[string]): bool =
## This example fetches a json, parse it and get specific value
let
node = parseJson "https://dummyjson.com/products/1".httpGet.body
title = node{"title"}.getStr
description = node{"description"}.getStr
echo title
echo description
result = title.len > 0 # Return success if there's a titleThere's more procs than just std, you can download files with just one command, encrypt and decrypt strings (using same algorithm that is encoded the data.enc) and more
Soon I will finish the documentation
Want to import some remote file? No problems!
Just download it by using this syntax:
# Note the mandatory space after `>`
#> staticDownload "https://example.com/file.txt"and import it, see the full example:
#> staticDownload "https://git.ozzuu.com/thisago/util/raw/branch/master/src/util/forStr.nim"
import forStr
proc main*(params: seq[string]): bool =
echo "Hello John Doe!".between("llo ", " Do") # -> JohnLimitations:
- You cannot specify the destination
- The URL cannot contains double quotes (
") - One download per line
- Ignores any download error and proceeds
- Add possibility to add multiple aliases to same script
- Add a possibility to reuse same encryption key (instead compilation time), maybe provide in nimble file
- Add option to run again x times until the raised exception stop to be
raise in
runcommand - Add option to process the
mainreturn (bool)falseas a raised error and run the script until returns true - Add optional custom destination fot
staticDownloaddownloads - Add possibility to import pkg modules from nimble package list
- Add listed and unlisted scripts (now all is unlisted)
- Add
--helpin scripts, extract frommainproc doc comment - Add static files in config to pack it and with a internal proc call, access the file
- Add a lib extension file like
config/lib.nimto add more internal procs to the Nimscript scope, adding procs that cannot be ran in Nimscript, like ddl handling
MIT