NeoCurl
A command line tool to test servers.
Features
- Sending requests
- Running definintions at runtime
- Tests
- Logs
- Json support
- Running tests
Install
Make sure you have rust installed.
Install using cargo install neocurl.
Now neocurl and ncurl commands should be available.
Usage
- Create a new file (default name is
neocurl.lua) - Add request definitions. Example:
define
- Run via
ncurl run get_request
Advaced
Use checks, helpers, tests, runs, and async.
-- Check the NeoCurl version
check_version
define
define
define
Guide
Args
--fileor-fand<string>: Set the file path. Default isneocurl.lua. Ex.neocurl -f ncurl_custom_file.lua- Commands:
list: List all definitions from the file.runand<name>: Run a definition from the file.repl: Run REPL.
Functions
Definitions
define({name, test, func}): Creates a new definition withname,funcis executed when called, andteststates if it should be run as a test (default istrue).
Runs
run(name, Option<amount>): Run a definition by name. Optional amount specifies the amount of subsequent calls, default is 1.run_async(names, Option<amount>, Option<delay>): Run a definitions specified in the names table (Ex.{"run1", "run2"}). Optionalamountspecifies the amount of subsequent calls, default is 1. Optionaldelayspecifies delay between async calls in milliseconds, default is 100ms (if set too low, unexpected behaivor might occur as the amount of threads is not limited).
Log
debug(message): Logmessagewith debug level.info(message): Logmessagewith info level.warn(message): Logmessagewith warn level.error(message): Logmessagewith error level.
Test
If any test fails in run command, the tool will exit with exit code of 1 (Use in CI/CD? :D).
assert(condition, fail_func): Asserts thatconditionistrue, if not, runsfail_func.
Helpers
time: Returns timestamp in millis since the epoch.format_time(format_str): Returns time formatted using format_str. Ex.format_time("%Y-%m-%d %H:%M:%S")to_base64(payload): Encodespayloadin base64.from_base64(base64): Decodes from base64dump(value): Dumpsvalueto a string and returns it. Useful for debugging tables. Ex.print(dump(tbl))
Checks
check_version(version): Checks ifversionand current NeoCurl version are the same. Version is in Semantic Versioning (major.minor.patch), settingpatchto*will ignore patch check. Ex.check_version("1.2.*").
Import
import(path): Returns code loaded from a lua file located atpath. Ex.yaml = import("yaml_lib.lua")load(path): Returns content loaded from a file located atpath. Ex.payload = import("payload.json")download(url): Returns file downloaded from url.
Built-in Libs
Json
dkjson is used to encode/decode json. Example usage:
define