/nebula-console

Command line interface for the Nebula Graph service

Primary LanguageGoApache License 2.0Apache-2.0

Nebula Graph Console

This repository contains the Nebula Graph Console for Nebula Graph 2.0.

Features

  • Supports interactive and non-interactive mode.
  • Supports viewing the history statements.
  • Supports autocompletion.
  • Supports multiple OS and architecture (We recommend Linux/AMD64).

Build Nebula Graph Console

To build Nebula Graph Console, make sure that you have installed Go.

Run the following command to examine if Go is installed on your machine.

$ go version

Use Git to clone the source code of Nebula Graph to your host.

$ git clone git@github.com:vesoft-inc/nebula-console.git

Run the following command to build Nebula Graph Console.

$ cd nebula-console
$ make

Connect to Nebula Graph Console

To connect your Nebula Graph services with the Nebula Graph Console, use the following command.

$ ./nebula-console -addr <ip> -port <port> -u <username> -p <password>
    [-t 120] [-e "nGQL_statement" | -f filename.nGQL]
Option Description
-h Shows the help menu.
-addr Sets the IP address of the graphd service. The default address is 127.0.0.1.
-port Sets the port number of the graphd service. The default port number is 3699.
-u/-user Sets the username of your Nebula Graph account. The default username is root.
-p/-password Sets the password of your Nebula Graph account. The default password for the root user is nebula.
-t/-timeout Sets an integer-type timeout threshold for the connection. The unit is second. The default value is 120.
-e/-eval Sets a string-type nGQL statement. The nGQL statement is executed once the connection succeeds. The connection stops after the result is returned.
-f/-file Sets the path of an nGQL file. The nGQL statements in the file are executed once the connection succeeds. You'll get the return messages and the connection stops then.

Check options for ./nebula-console -h, try ./nebula-console in interactive mode directly. And try ./nebula-console -e 'show hosts' for the direct script mode. And try ./nebula-console -f demo.nGQL for the script file mode.

Export mode for Nebula Graph Console

When the export mode is enabled, Nebula Graph Console exports all the query results into a CSV file. When the export mode is disabled, the export stops. The syntax is as follows.

NOTE: The following commands are case insensitive.

  • Enable nebula-console export mode:
nebula> :SET CSV <your_file.csv>
  • Disable nebula-console export mode:
nebula> :UNSET CSV

Disconnect Nebula Graph Console from Nebula Graph

You can use :EXIT or :QUIT to disconnect from Nebula Graph. For convenience, nebula-console supports using these commands in lower case without the colon (":"), such as quit.

nebula> :QUIT

Bye root!

nebula> :EXIT

Bye root!

nebula> quit

Bye root!

nebula> exit

Bye root!

Keyboard Shortcuts

Key Binding Description
Ctrl-A, Home Move cursor to beginning of line
Ctrl-E, End Move cursor to end of line
Ctrl-B, Left Move cursor one character left
Ctrl-F, Right Move cursor one character right
Ctrl-Left, Alt-B Move cursor to previous word
Ctrl-Right, Alt-F Move cursor to next word
Ctrl-D, Del (if line is not empty) Delete character under cursor
Ctrl-D (if line is empty) End of File --- quit from the console
Ctrl-C Reset input (create new empty prompt)
Ctrl-L Clear screen (line is unmodified)
Ctrl-T Transpose previous character with current character
Ctrl-H, BackSpace Delete character before cursor
Ctrl-W, Alt-BackSpace Delete word leading up to cursor
Alt-D Delete word following cursor
Ctrl-K Delete from cursor to end of line
Ctrl-U Delete from start of line to cursor
Ctrl-P, Up Previous match from history
Ctrl-N, Down Next match from history
Ctrl-R Reverse Search history (Ctrl-S forward, Ctrl-G cancel)
Ctrl-Y Paste from Yank buffer (Alt-Y to paste next yank instead)
Tab Next completion
Shift-Tab (after Tab) Previous completion

TODO

  • CI/CD
  • package to RPM/DEB/DOCKER
  • batch process to reduce memory consumption and speed up IO