spvm − Executing SPVM programs
The spvm command executes SPVM programs.
Usage: spvm
[OPTIONS] SCRIPT_NAME
spvm myapp.spvm
Options:
−h, −−help Shows this message
−v, −−version Shows the version
−I, −−include−dir DIRECTORY Adds a
include directory
−B, −−build−dir DIRECTORY Build
diretory
−e SOURCE Executes a program source code in main
method.
−c Check syntx only
spvm [OPTIONS] SCRIPT_NAME
The "spvm" command executes a SPVM program.
OPTIONS are options.
SCRIPT_NAME is a script path that contains an SPVM script.
# myapp.spvm
use Fn;
my $var = 1;
say $var;
Anon class that contains a bootstrap method is allowed as an SPVM script.
# myapp.spvm
class {
version "1.001";
our $FOO : int;
use Fn;
static method main : void () {
my $var = 1;
say $var;
}
}
The base name of SCRIPT_NAME must be a "Script Base Name". Otherwise an exception is thrown.
See Class Search Directories about default class search directories.
See SPVM::Document::EnvironmentVariables about available environment variables.
A script base name ends with ".spvm".
A script base name without ".spvm" consists of word characters and "−".
It dose not contains "__".
It dose not begin with "0−9".
It dose not begin with "−".
It dose not end with "−".
It dose not contains "−−".
Examples:
# Script Base
Names
foo.spvm
foo_bar2.spvm
myapp−foo.spvm
# Invalid Script Base Names
2foo.spvm
foo__bar.spvm
−myapp.spvm
myapp−.spvm
myapp−−foo.spvm
Outputs how to use the "spvm" command to standard output.
−h
Same as "−−help".
Outputs the version of the "spvm" command to standard output. This version is the same as the version of SPVM.
−v
Same as "−−version".
−−include−dir DIRECTORY
Prepends DIRECTORY to class search directories
This option can be specified multiple times.
−−include−dir dir1 −−include−dir dir2
In this case, class search directories becomes the following.
[dir1, dir2, default_dirs]
−I DIRECTORY
Same as "−−include−dir".
−−build−dir DIRECTORY
Sets SPVM_BUILD_DIR environment variable to DIRECTORY.
−B DIRECTORY
Same as "−−build−dir".
−e SOURCE
Executes a source code SOURCE in "main" method.
Examples:
spvm −e 'say "Hello World!";';
−c
Checks syntax only.
−w
Enables warning flag.
Implementation:
Sets CommandInfo#WARNING class variable to 1.
If the source code specified by SCRIPT_NAME, or "−e" option contains lib directives, The directories specified by lib directive is prepeneded to class search directories.
#lib "$FindBin::Bin/lib"
This directories specified by lib directive is placed after the directories specified by "−−include−dir" option.
Copyright 2023 Yuki Kimoto. All Rights Reserved.
MIT License.