Command line (total5)
Every command and argument of the total5 and flow5 programs.
On this page
The commands of the two programs that the total5 package installs: total5, which works on the current directory, and flow5, which runs FlowStream schemas. Each entry shows the syntax, the arguments and an example. For an introduction read Command line (total5).
npm install -g total5
total5 help
flow5API
command
total5 [command] [arguments]
The command-line toolbox of the total5 package.
total5 [command] [arguments]| Parameter | Type | Description |
|---|---|---|
command? |
String |
The name of the command. Default: help |
arguments? |
String |
The arguments of the command, in order. |
Runs one command on the current directory. Without a command it shows the help. Each command prints * Total.js v5: [Command] first; the short ones end with a [Done] line with the time they took. A command the program does not know prints only that header.
total5
command
total5 help
Prints the list of commands.
total5 helpPrints one line for each command with its arguments and what it does: translate, minify, bundle, extract, edit, proxy, test and the web server (8000). total5 with no command does the same.
total5 help
total5 --help
command
total5 --<command> [arguments]
Dashes in front of a command are ignored.
total5 --<command> [arguments]The program removes every run of two or more dashes from the command, so --help is help and --minify is minify. Use the form you prefer.
total5 --help
total5 help
command
total5 minify <filename>
Minifies a JavaScript, CSS or HTML file.
total5 minify <filename>| Parameter | Type | Description |
|---|---|---|
filename |
String |
The full path of the file to minify. |
Reads the file, minifies it by its extension and writes the result next to it as name.min.ext. JavaScript and CSS are fully minified. The HTML minifier removes comments, shortens runs of spaces inside the markup and minifies inline <script> and <style> blocks; it keeps the line breaks and the indentation between tags. A file with another extension is copied without change. It prints the input and the output file names. Give the full path of the file.
total5 minify "$PWD/public/js/app.js"
# Output : /home/me/shop/public/js/app.min.js
command
total5 edit <url>
Opens the current directory for remote editing in the Total.js Code Editor.
total5 edit <url>| Parameter | Type | Description |
|---|---|---|
url |
String |
The address of the project in the Code Editor, for example https://code.example.com/?id=project. |
Connects to the URL of the project with a WebSocket (http and https become ws and wss) and serves the requests of the editor on the current directory (see Code Editor requests). When the editor accepts the connection it prints a welcome with the name of the editor and of the project. The connection reconnects every 10 seconds and is pinged every 30 seconds. 404 project not found and 409 project is already open are printed when the editor refuses the project. Without a URL the program throws Invalid URL address.
cd ~/projects/shop
total5 edit "https://code.example.com/?id=shop"
type
TYPE: browse | load | save | ...
What the Code Editor can do through total5 edit.
TYPE: browse | load | save | ...The editor sends requests and the program answers them inside the current directory: browse (the list of files and folders), load, save, create, remove, rename, modify, info, upload, download, send, import, log and logclear (log files), wiki, ip (the public IP address), exec (runs a file: .js files with Node.js, .sh files with sh, or a command the editor sends), restart and ping. An unknown request is answered with an error 400.
// sent by the editor
{ TYPE: 'browse', data: '{}' }
// answer
{ TYPE: 'browse', data: '{}', success: true, response: { files: ['/index.js'], directories: ['/controllers/'] } }
command
total5 <port>
Starts a static web server for the current directory on the given port.
total5 <port>| Parameter | Type | Description |
|---|---|---|
port |
Number |
The port of the server. |
A number as the command starts the web server: total5 8000 is total5 server 8000. The current directory is the public folder, minification and source maps are off, and the application folders are not loaded. A directory URL shows a listing of the directory. The program prints the start information of the framework and runs until you stop it.
cd ~/projects/landing
total5 8000
# open http://127.0.0.1:8000/
command
total5 proxy <endpoint> <port>
since 0.0.17
Connects a local port to a remote Total.js proxy server.
total5 proxy <endpoint> <port>| Parameter | Type | Description |
|---|---|---|
endpoint |
String |
The WebSocket address of the proxy server. |
port |
String |
A local port (on 127.0.0.1) or an ip:port pair. |
Opens a WebSocket to the proxy server, an application that calls PROXYSERVER() (http and https are replaced with ws and wss), and forwards every request that arrives through it to the local address. The answer goes back the same way. The program prints a line when it connects or disconnects and one line for each request with its method, the IP address of the visitor and the URL. Without both arguments it prints client [WSS proxy server] [port or ip:port]. It is the same client as the PROXYCLIENT() function.
total5 proxy wss://proxy.example.com/ 8000
// index.js of the proxy server
require('total5');
PROXYSERVER('/', '/proxy/');
F.http({ port: 8000, load: 'none' });
// on your machine:
// total5 proxy wss://proxy.example.com/proxy/ 8000
command
total5 server [port]
Starts a static web server for the current directory.
total5 server [port]| Parameter | Type | Description |
|---|---|---|
port? |
Number |
The port of the server. Default: 8000 |
The long form of total5 <port>. Without a port it listens on 8000.
total5 server
# http://0.0.0.0:8000/
total5 server 8080
command
total5 test [name1] [name2] [...]
Runs the unit tests of the current directory.
total5 test [name1] [name2] [...]| Parameter | Type | Description |
|---|---|---|
name? |
String |
The name of a test script without .js; several names with spaces or commas. |
Takes the tests directory of the current directory, or the current directory when there is no tests directory. It loads the config file of that directory with LOADCONFIG(), creates the global Test, loads init.js when it exists and then the named scripts in their order, or every .js file except init.js in alphabetical order when no name is given. Then it calls Test.run(). Names can be separated with spaces or commas and the .js extension is optional. A missing script prints ERROR: the test "name" not found (path) and ends with exit code 1. The exit code is 0 when all groups are done and 1 when a check fails or the run stops before the end. The command uses the total5 package installed in the current directory or in a parent directory (so it also runs from tests), otherwise its own package. The application itself is not started and the current directory is the root (PATH.root()). See Unit tests.
cd ~/projects/shop
total5 test
total5 test strings orders
total5 test strings,orders
command
flow5
Prints the help of the Flow engine.
flow5Without arguments flow5 prints [Total.js v5 Flow Engine] and the ways to call it.
flow5
# flow5 [path or URL address] [PORT_NUMBER]
# flow5 path/to/flowschema.json
# flow5 flow1.json flow2.json flowN.json 8001
# flow5 https://yourdomain.com/flowschema.json
type
GET /{path}/
What the web server shows for a directory.
GET /{path}/For a directory URL the server shows an HTML page with a .. link to the parent (except at /), the subdirectories and the files with their sizes. Every link opens the item on the same server; open index.html from the listing like any other file.
total5 8000
# http://127.0.0.1:8000/ -> the listing of the directory
# http://127.0.0.1:8000/index.html -> the page
command
total5 translate <filename>
Collects the @(...) texts of the current directory into a resource file.
total5 translate <filename>| Parameter | Type | Description |
|---|---|---|
filename |
String |
The full path of the resource file to write. |
Reads every .js and .html file of the current directory and of all its subdirectories, finds the texts written as @(text) (nested parentheses are kept) and writes them into the resource file, one KEY : text line for each text. The same text gives one line. An existing file is overwritten. Give the full path of the file.
total5 translate "$PWD/resources/default.resource"
command
flow5 <file> [port]
Runs the flows of a local schema file.
flow5 <file> [port]| Parameter | Type | Description |
|---|---|---|
file |
String |
The full path of the schema file. |
port? |
Number |
The port of the HTTP server. Default: 8000 |
Loads the FlowStream schema of the file and runs it. The HTTP server starts when at least one flow is loaded. For each flow the program prints a link to the Flow editor. When the flow is saved in the editor, the file is written again as JSON indented with tabs. A file that is not valid JSON prints ERROR: invalid meta - <path> and is skipped. Give the full path of the file.
flow5 "$PWD/flowschema.json"
# |--- http://127.0.0.1:8000
# |--- Orders: https://flow.totaljs.com/?socket=...
command
flow5 <url> [port]
Runs the flows of a schema downloaded from an https address.
flow5 <url> [port]| Parameter | Type | Description |
|---|---|---|
url |
String |
The https:// address of the schema. |
port? |
Number |
The port of the HTTP server. Default: 8000 |
An argument that starts with https:// is downloaded with a GET request and loaded like a file. The certificate of the server is checked. Changes made in the editor are not saved anywhere for these flows.
flow5 https://example.com/flowschema.json 8001
type
KEY : text
The file that total5 translate writes.
KEY : textA plain text file with one line for each text: the key, padded to 12 characters, then : and the text. The key is T followed by a hash of the text in base 36, the key that the view engine looks up for @(text). Put a translated copy into resources/ (for example resources/sk.resource) and translate the right side. See Localization.
T1l964ro : Hello world
T1j2ql : Save
command
flow5 <files...> <port>
Sets the port of the Flow engine and runs several schemas at once.
flow5 <files...> <port>| Parameter | Type | Description |
|---|---|---|
files |
String |
One or more schema files or addresses. |
port? |
Number |
The port of the HTTP server. Default: 8000 |
Arguments can come in any order. Every argument made only of digits is the port (the last one wins); every other one is a schema file, with its full path, or an https:// address. All the flows of all the sources run in one process on that port.
flow5 "$PWD/flow1.json" "$PWD/flow2.json" 8001
command
total5 bundle <filename>
Packs the current directory into a bundle file.
total5 bundle <filename>| Parameter | Type | Description |
|---|---|---|
filename |
String |
The full path of the bundle file. |
Writes the files of the current directory and its subdirectories into one .bundle file. .bundle is added to the name when it is missing. The machine files are left out (see Bundle content). Give the full path of the bundle, outside the directory you pack. The framework unpacks the bundles of bundles/ when it starts.
cd ~/projects/shop
total5 bundle ~/backups/shop
# ~/backups/shop.bundle
type
{ id, name, components, design } | { <id>: schema }
The two shapes of a file that flow5 reads.
{ id, name, components, design } | { <id>: schema }A file with one flow is an object with components and design (and id, name and the other fields of a FlowStream schema). A file with several flows is an object whose keys are the ids of the flows; a variables key is skipped. A flow without id gets an id made from the path. To save changes back into the file, give the flow an id, and in a file with several flows use the id as its key.
{
"id": "orders",
"name": "Orders",
"components": {},
"design": {}
}
{
"orders": { "id": "orders", "name": "Orders", "components": {}, "design": {} },
"mail": { "id": "mail", "name": "Mail", "components": {}, "design": {} }
}
type
.bundle
Which files total5 bundle puts into a bundle.
.bundleAll the files of the directory, except: /index.js, /debug.js, /release.js with their .json and .pid files, /bundle.json, /package.json, /readme.md, /license.txt and the folders /bundles/, /tmp/, /.src/ and /.git/.
total5 bundle ~/backups/shop
scp ~/backups/shop.bundle server:/www/shop/bundles/
property
GET|POST /notify/{id}/
The notification route of the Flow engine.
GET|POST /notify/{id}/| Parameter | Type | Description |
|---|---|---|
id |
String |
<flow id>-<instance id>[-param...]. |
Sends a notification to a component instance of a running flow. The id is <flow id>-<instance id>; more parts separated with - arrive as params. The component gets the method, headers, query, body (up to 1 MB), URL and IP address. A REDIRECT query value redirects the visitor; a browser gets a page that closes itself, other clients get a success answer. See FlowStream.
curl -X POST -d '{"paid":true}' -H "Content-Type: application/json" http://127.0.0.1:8000/notify/orders-c1x8a/
command
total5 extract <filename>
Unpacks a bundle into the current directory.
total5 extract <filename>| Parameter | Type | Description |
|---|---|---|
filename |
String |
The full path of the bundle file to unpack. |
Restores all the files of the bundle into the current directory, with their subdirectories. Existing files with the same names are overwritten. When the argument is a directory, nothing happens. Give the full path of the file.
mkdir shop-copy && cd shop-copy
total5 extract ~/backups/shop.bundle
property
SOCKET /flowstreams/{id}/
The WebSocket of the Flow editor.
SOCKET /flowstreams/{id}/| Parameter | Type | Description |
|---|---|---|
id |
String |
The id of the flow. |
The Flow editor connects here to show and change the flow with the given id (messages up to 8 MB). The link that flow5 prints for each flow opens https://flow.totaljs.com/?socket= with this address.
https://flow.totaljs.com/?socket=http%3A%2F%2F127.0.0.1%3A8000%2Fflowstreams%2Forders%2F