Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nautilus CLI #1602

Merged
merged 5 commits into from
Apr 21, 2024
Merged

Nautilus CLI #1602

merged 5 commits into from
Apr 21, 2024

Conversation

filipmacek
Copy link
Member

Pull Request

  • created a docker-compose.yml file in .docker directory to help bootstrap all the services used by nautilus system
  • added new Makefile target install-cli that build and install nautilus CLI executable
  • updated docs/developer_guide/environment_setup.md with documentation around running services with docker-compose, how to build and use nautilus cli, and which commands are currently implemented
  • created a new cli rust crate that contains Rust CLI design with target commands
  • fixed build.rs warning when running install-cli by conditionally importing std env based on FFI feature (to suppress warnings)
  • WIP SQL Nautilus in schema/tables.sql that is being heavy developed

Demo

Screenshot 2024-04-21 at 12 36 16

Steps to reproduce and try

Services

You can use docker-compose.yml file located in .docker directory
to bootstrap the Nautilus working environment. This will start the following services:

docker-compose up -d

If you only want specific services running (like postgres for example), you can start them with command:

docker-compose up -d postgres

Used services are:

  • postgres - Postgres database with root user POSTRES_USER which defaults to postgres, POSTGRES_PASSWORD which defaults to pass and POSTGRES_DB which defaults to postgres
  • redis - Redis server
  • pgadmin - PgAdmin4 for database management and administration

Note: Please use this as development environment only. For production, use a proper and more secure setup.
After the services has been started, you must login with psql cli to create nautilus Postgres database.
To do that you can run, and type POSTGRES_PASSWORD from docker service setup

psql -h localhost -p 5432 -U postgres

After you have long as postgres administrator, run CREATE DATABASE command with target name( we use nautilus):

psql (16.2, server 15.2 (Debian 15.2-1.pgdg110+1))
Type "help" for help.
postgres=# CREATE DATABASE nautilus;
CREATE DATABASE

Nautilus CLI Developer Guide

Introduction

The Nautilus CLI is a command-line interface tool designed to interact
with the Nautilus Trader ecosystem. It provides commands for managing the Postgres database and other trading operations.

Note: The Nautilus CLI command is only supported on UNIX-like systems.

Install

You can install nautilus cli command with from Make file target, which will use cargo install under the hood.
And this command will install nautilus bin executable in your path if Rust cargo is properly configured.

make install-cli

Commands

You can run nautilus --help to inspect structure of CLI and groups of commands:

Database

These are commands related to the bootstrapping the Postgres database.
For that you work, you need to supply right connection configuration. You can do that through
command line arguments or .env file in the root directory or where the commands is being run.

  • --host arg or POSTGRES_HOST for database host
  • --port arg or POSTGRES_PORT for database port
  • --user arg or POSTGRES_USER for root administrator user to run command with (namely postgres root user here)
  • --password arg or POSTGRES_PASSWORD for root administrator password
  • --database arg or POSTGRES_DATABASE for both database name and new user that will have privileges of this database
    ( if you provided nautilus as value, then new user will be created with name nautilus that will inherit the password from POSTGRES_PASSWORD
    and nautilus database with be bootstrapped with this user as owner)

Example of .env file

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USERNAME=postgres
POSTGRES_DATABASE=nautilus
POSTGRES_PASSWORD=pass

List of commands are:

  1. nautilus database init - it will bootstrap schema, roles and all sql files located in schema root directory (like tables.sql)
  2. nautilus database drop - it will drop all tables, role and data in target Postgres database

@filipmacek filipmacek added the rust Relating to the Rust core label Apr 21, 2024
@filipmacek filipmacek requested a review from cjdsellers April 21, 2024 13:33
@filipmacek filipmacek self-assigned this Apr 21, 2024
@cjdsellers
Copy link
Member

Awesome stuff 🚀.

@cjdsellers cjdsellers merged commit 13a42b0 into develop Apr 21, 2024
9 checks passed
@cjdsellers cjdsellers deleted the nautilus-cli branch April 21, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Relating to the Rust core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants