Skip to content

Tools

Novis comes with its own tools for writing, testing and debugging a program. Most of them are commands of the nvs program, so you install them when you install Novis. Each picture below is made from a real run of the tool.

The editor extension adds Novis to VS Code. It colours your code, shows errors while you type and completes names.

How it looks in your editorA recording from the Novis editor extension. You cannot type here.
What this recording shows
  1. Type em. A list of suggestions opens. It shows email.
  2. Press Enter to choose email.

The formatter is nvs fmt. It changes the layout of your code to one fixed style.

Terminal: diff
nvs fmt --diff cart.nvs--- cart.nvs+++ cart.nvs@@ -1,11 +1,15 @@ <?nvs-class Cart {-  public int $total = 0;-      public function add(int $price): void {-        $this->total = $this->total + $price; }+class Cart+{+    public int $total = 0;+    public function add(int $price): void+    {+        $this->total = $this->total + $price;+    } } Cart $cart = new Cart();-$cart->add(1200); $cart->add(350);-   echo $cart->total, "\n", "done";+$cart->add(1200);+$cart->add(350);+echo $cart->total, "\n", 'done';exit 1

The test runner is nvs test. It runs your tests and can write a coverage report.

Terminal: prices
nvs test prices.nvs  PriceTest    ✓ addsTwentyPercent                0.3 ms    ✓ zeroStaysZero                    0.3 ms    - roundsHalfCents                  0.0 ms      skipped: rounding is not decided yet  0 failed, 2 passed, 1 skipped, 0 flaky in 1 ms

The command line is the nvs program itself: nvs run, nvs check, nvs serve and the other commands.

Terminal: check
nvs check cart.nvsno errorsnvs check order.nvserror[E0401]: expected `int`, found `string`  --> order.nvs:8:17  |8 | $order->total = 'seven';  |                 ^^^^^^^ this is `string`error: aborting due to 1 errorTo read what a code means and how to fix it, run `nvs agent show <code>`.exit 1

The debugger stops your program at a line, so you can look at its variables. Your editor connects to it through nvs dap.

How it looks in your debuggerA recording of a debug session in the Novis editor extension. You cannot type here.
What this recording shows
  1. Set a breakpoint on line 7 and start debugging. The program stops on line 7. $words is array(3), $total is 0 and $count is 120.
  2. Press F5 to continue. The program stops on line 7. $words is array(3), $total is 120 and $count is 340.
  3. Press F5 to continue. The program stops on line 7. $words is array(3), $total is 460 and $count is 95.
  4. Press F5 to continue. The program runs to its end. It ends with exit code 0.

The debug viewer is nvs debug. It shows in your browser each request that your server handled.

The request list with four GET requests. Each row shows the route, such as App::home, the status 200 or 404, and 2 queries.

The profiler shows where your program spends its time.

The speedscope view of main.nvs. It lists Fibonacci::square with 10 calls and Fibonacci::at with 1973 calls.

The API document is the OpenAPI description of your routes. nvs build --openapi writes it.

Terminal: build
nvs build --openapi shop.nvs{  "info": {    "title": "shop",    "version": "0.0.0"  },  "openapi": "3.1.0",  "paths": {    "/orders/{id}": {      "get": {        "operationId": "Orders.show",        "parameters": [          {            "in": "path",            "name": "id",            "required": true,            "schema": {              "minimum": 0,              "type": "integer"            }          }        ],        "responses": {          "200": {            "content": {              "application/json": {                "schema": {                  "type": "string"                }              }            },            "description": "success"          }        },        "summary": "Shows one order."      }    }  }}