Introduction

The Latitude CLI is a command-line tool that allows you to manage your Latitude projects. It provides a set of commands to help you create and serve your Latitude projects.

To get a list of all available commands, you can run the following command:

latitude --help

Creating a new project

To create a new Latitude project, you can use the start command. This command will create a new directory with the specified project name and initialize it with the necessary files and folders.

latitude start

The start command will prompt you to enter the name of your new project. Once you’ve entered the name, the command will create a new directory with the specified name and initialize it with the necessary files and folders.

Local development

To serve your Latitude project locally, you can use the dev command. This command will start a local development server that will serve your project on http://localhost:3000.

latitude dev

Running queries

To check that your queries are working as expected, you can run them locally using the run command. For example:

latitude run sample

This will run the /queries/sample.sql query once and display the results in your terminal.

If your query is in a sub-folder within the /queries folder, make sure to include the sub-folder name in the command. For example:

latitude run sub-folder/sample

Watch mode

If you want to run the query in watch mode, you can add the -w or --watch flag to the command. For example:

latitude run sample --watch

With this, every time you save the file, the query will be re-run and the results will be displayed in your terminal.

Passing parameters

If you’re using parameters in your query, you can pass them to the run command using the --param flag, followed by the parameter name and value. For example:

latitude run sample --param name=Latitude --param id=1

Now, when building the query with the parameters, the name and id parameters will receive the values Latitude and 1, respectively.

Debugging queries

You can use the --debug flag to display the actual query that would be sent to your database, without actually running it. For example:

latitude run sample --debug