0.1.2 • Published 6 years ago
liyad-cli v0.1.2
Liyad CLI
CLI and REPL for Liyad (Lisp yet another DSL interpreter).
Requirements
- Node >= 10
Install
$ npm install -g liyad-cli
$ liyad --versionCLI Usage
Usage: liyad [options] [ -- ] [ -e script | script.lisp | - ] [ -- ] [arguments]
liyad [options]
Options:
- script read from stdin (default; interactive mode if a tty)
-- indicate the end of CLI options / script files
-p, --profile=... select interpreter profile
S S-expression parser
L, lisp (default) lisp interpreter (return single value)
LM lisp interpreter (return multiple values)
L_async, lisp_async lisp interpreter (return single value, enable async)
LM_async lisp interpreter (return multiple values, enable async)
LSX lisp interpreter (return single value, enable LSX)
LSX_async lisp interpreter (return single value, enable LSX, enable async)
--lsx-boot lsxboot.js LSX bootstrap JavaScript file; required if profile LSX or LSX_async is selected.
--safe run as safe mode (disable '$require' and '$node-require')
-e, --eval=... evaluate script
-i, --interactive always enter the REPL even if stdin does not appear to be a terminal
-h, --help print command line options
-v, --version print version informations
--cli-version print cli version informationsLSX bootstrap file example
lsxboot.js
const React = require('react');
const ReactDOMServer = require('react-dom/server');
class Hello extends React.Component {
render() {
return (React.createElement("div", {}, "hello"));
}
}
exports.dom = React.createElement;
exports.flagment = React.Fragment;
exports.render = ReactDOMServer.renderToStaticMarkup;
exports.components = {
Hello,
};Packaging to the single executable file.
Use pkg.
$ npm install -g pkg
$ git clone https://github.com/shellyln/liyad-cli.git
$ cd liyad-cli
$ npm ci
$ pkg . --output liyad
$ ./liyad --versionPackaging and publish your codes as the NPM module.
See liyad-lisp-pkg-example and liyad-webapp-example
Usage of package:
$ npm install -g liyad-cli
$ mkdir myapp
$ cd myapp
$ npm install liyad-lisp-pkg-example
$ vi app.lispapp.lisp
($let ex ($require "liyad-lisp-pkg-example"))
;; Benchmarks
($console-log (::ex:tarai 12 6 0))
($console-log (::ex:fib 10))
($console-log (::ex:fac 10))
;; Run the web server on port 3000.
($let url ($node-require "url"))
(::ex:#get "/" (-> (req res)
($let u (::url:parse ::req:url))
(::res@writeHead 200 (# (Content-Type "text/html")))
(::res@end ($concat "hit / ," ::req:method "," ::u:path)) ) )
(::ex:serve 3000) ($last "start server")$ liyad app.lisp
12
55
3628800
start serverAdditional operators and constants
$exit
($exit [ code ])- Exit the process.
- returns: never.
code: exit code.
$shell
($shell command)- Run command.
- returns: command output (stdout) string.
command: command and arguments.- example:
($shell "ls -al")
- example:
$shell-async
($shell-async command)- Run command asynchronously.
- returns: Promise object resolving command output (stdout) string.
command: command and arguments.- example:
($shell-async "ls -al")
- example:
$require
($require id [ profile ])- Load lisp code from other file.
- returns: Exported functions and variables.
id: Load from relative path ifidstarts with./or../. Otherwise load from local or globalnode_modules.profile: (optional) interpreter profile (S/L/lisp/LM/L_async/lisp_async/LM_async).- default value is selected by CLI option
-por--profile.
- default value is selected by CLI option
$node-require
($node-require id)- Load JavaScript code from other file.
- returns: Exported functions and variables.
id: Load from relative path ifidstarts with./or../. Otherwise load from local or globalnode_modules.
$render
($render jsxElement callback)- Render jsxElement by
LSX-bootstrap.render()and pass rendering result string or error tocallback. - returns:
undefined jsxElement: object returned byLSX-bootstrap.dom().callback(error, html): callback function called on end of renderingjsxElement.error: not null if error is occured.html: rendering result html; null if error is occured.
- Render jsxElement by
Additional operator on REPL
$pause
($pause [ cond ])- Pause execution and start debugger
- returns:
undefined cond: if it present, pause if condition istrue.
API
parseArgs
parseArgs(args)- Parse CLI arguments.
- returns: config object.
args: CLI arguments.
- example:
parseArgs(['-p', 'LSX_async', '--lsx-boot', 'lsxboot.js', 'app.lisp'])
cliCore
cliCore(curDir, params)- Evaluate codes.
- returns:
undefined curDir: current directory.params: config object.
- example:
cliCore(fs.realpathSync(process.cwd()), parseArgs(process.argv.slice(2)))
cli
cli()- Run CLI.
- returns:
undefined
License
ISC
Copyright (c) 2018, Shellyl_N and Authors.
0.1.2
6 years ago
0.1.1
6 years ago
0.1.0
6 years ago
0.0.49
6 years ago
0.0.48
6 years ago
0.0.47
6 years ago
0.0.46
7 years ago
0.0.45
7 years ago
0.0.44
7 years ago
0.0.43
7 years ago
0.0.42
7 years ago
0.0.41
7 years ago
0.0.40
7 years ago
0.0.39
7 years ago
0.0.38
7 years ago
0.0.37
7 years ago
0.0.36
7 years ago
0.0.35
7 years ago
0.0.34
7 years ago
0.0.33
7 years ago
0.0.32
7 years ago
0.0.31
7 years ago
0.0.30
7 years ago
0.0.29
7 years ago
0.0.28
7 years ago
0.0.27
7 years ago
0.0.26
7 years ago
0.0.25
7 years ago
0.0.24
7 years ago
0.0.23
7 years ago
0.0.22
7 years ago
0.0.21
7 years ago
0.0.20
7 years ago
0.0.19
7 years ago
0.0.18
7 years ago
0.0.17
7 years ago
0.0.16
7 years ago
0.0.15
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.12
7 years ago
0.0.11
7 years ago
0.0.10
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago