Source

kink / man / man1 / kink.1

.TH KINK 1 "2013-10-21" kink "Kink User's Manual"

.SH NAME
kink \- interpreter of the Kink programming language

.SH SYNOPSIS

.TP
\fBkink\fR [\fILaunchOptions\fR]... [\fIStandardOptions\fR]...
Executes the REPL (interactive shell).

.TP
\fBkink\fR [\fILaunchOptions\fR]... [\fIStandardOptions\fR]... [--] \fIFILE\fR [\fIARGS\fR]...
Executes a program read from the \fIFILE\fR.

.TP
\fBkink\fR [\fILaunchOptions\fR]... [\fIStandardOptions\fR]... [--] \fB-\fR [\fIARGS\fR]...
Executes a program read from the standard input.

.TP
\fBkink\fR [\fILaunchOptions\fR]... [\fIStandardOptions\fR]... \fB-e\fR \fICODE\fR [--] [\fIARGS\fR]...
Executes the \fICODE\fR as a program.

.SH DESCRIPTION
The utility shall execute a program written in the Kink programming language.

If no parameter is specified except for options, the utility
shall launch the REPL (interactive shell).

If \fB-e\fR option is specified, the next parameter shall be executed as a program text,
and all the parameters which are not options shall be passed to the program as \fBArgv\fR.

Otherwise, if the first parameter which is not an option is `\fB-\fR',
the standard input shall be executed as a program.
The remaining parameters shall be passed to the program as \fBArgv\fR.

Otherwise, the file specified by the first parameter shall be executed as a program.
The remaining parameters shall be passed to the program as \fBArgv\fR.

.SH OPTIONS

There are two kinds of options.
Launch options are used to launch the interpreter on the JVM.
Standard options are used by the interpreter.

Launch options must be specified ahead of standard options and other parameters.

.SS Launch Options

.TP
\fB-J\fIjavaopt\fR / \fB-J \fIjavaopt\fR
Passes \fIjavaopt\fR to the JVM as an option.
If you want to pass multiple options to the JVM,
specify this \fB-J\fR option multiple times (ex. -J-Xms64M -J-Xmx128M).

.TP
\fB-C\fIpath\fR / \fB-C \fIpath\fR
Adds \fIpath\fR to the classpath.
If you want to add multiple paths to the classpath,
specify this \fB-C\fR option multiple times (ex. -C one.jar -C two.jar).

.TP
\fB-E\fIjavaexecutable\fR / \fB-E \fIjavaexecutable\fR
Use \fIjavaexecutable\fR as the executable file of the JVM to launch the interpreter
(ex. -E /opt/jdk/bin/java).
This option has a priority over the environment variable \fBJAVA_HOME\fR.
This option is useful to run jdb to debug the interpreter (ex. -E jdb).

.TP
\fB-V\fR
Turn on verbose mode, and set the log level to \fBINFO\fR.

.TP
\fB-V\fIlevel\fR
Turn on verbose mode, and set the log level to \fIlevel\fR.
Valid log levels are \fBERROR\fR, \fBWARN\fR, \fBINFO\fR, \fBDEBUG\fR and \fBTRACE\fR.

.SS Standard Options

.TP
\fB-e \fICODE\fR / \fB--executed \fICODE\fR
Executes the \fICODE\fR as a program.
All the parameters which are not options shall be passed to the program as \fBArgv\fR.

.TP
\fB-h\fR / \fB--help\fR
Prints out the help text and exit with the exit status 0.

.TP
\fB-v\fR / \fB--version\fR
Prints out the version and exit with the exit status 0.

.SH EXIT STATUS

The following exit values shall be returned.

.TP
.B 0
The program terminates normally.

.TP
.B Not 0
The interpreter fails to execute a program,
or the program terminates abnormally.

.SH ENVIRONMENT

The following environment variables shall affect the execution of the utility.

.TP
.B KINK_HOME
Directory where the interpreter is installed (ex. /opt/kink).
If the environment variable is not set,
the utility determines the directory based on the path of the utility itself.

.TP
.B JAVA_HOME
Home directory of the JVM which is used to launch the interpreter (ex. /opt/jdk).
This value is not used if the launch option \fB-E\fR is specified.
If the environment variable is not set and \fB-E\fR option is not specified,
the utility shall use \fBjava\fR command on the \fBPATH\fR environment variable.

.SH EXAMPLE

.TP
1. Emulates 'wc -l <some.txt'
kink -e 'printline(stdin.lineseq.count)' <some.txt

.TP
2. Emulates 'grep "^<h[1-6]" <some.html'
kink -e 'stdin.lineseq.select(%"<h[1-6].*").loop($print)' <some.html

.TP
3. Emulates 'cat -n some.txt'
.nf
#!/usr/bin/env kink
# USAGE: cat_n.kn some.txt

use('SEQ')
use('USING.using')
Argv.count == 1 || die('Requires a file')
using(path(Argv.first).in) { (:In)
    SEQ.zipseq(1.up In.lineseq).map { ([:Num :Line])
        expand("#Num\\t#Line")
    } .loop($print)
}
.fi

.SH SEE ALSO
The information about the utility and the language
can be found on the web site of the Kink programming language
(https://bitbucket.org/kink/kink).