postdigress

command module
v0.0.0-...-51a77ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 16 Imported by: 0

README

Post-Digress

Terminal UI application for PostgreSQL.

Demo

Written in Go, and forged from my struggles and frustations with psql, pgadmin and PostBird. It's intended to be simple, vi-based, faster than the overbloated ones and allow you to make you queries with ease.

Fetch'em

This project would'nt be possible without the following Go packages: pq, tview, tcell.

go get "github.com/lib/pq"
go get "github.com/rivo/tview"
go get "github.com/gdamore/tcell"

Run or Build

go run *.go
go build *.go

Mind you

Mouse is disabled for the aplication, at least for now.

Once you estabilish a connection with the database, the main page will be open to you. Notice that the menu has the focus and will be receiving any key event, and will make transition between the pages Execute, Structure, and Quit, each one indicating(underline) the key that should be pressed to make the transition to that page.

Pages

  • Execute: Has an editor, a table viewer and a status bar at bottom.

    1. Press Ctrl-E to enter the editor. You can navigate thought the text using the several vi-like keybindings. The supported ones are h, j, k, l, w, e, b, i, a, x, o, O, p, r, d, y. Press v and j or k to select the queries you wish to execute. Press q, on select mode, to put you back on normal mode. Press q, on normal mode, to exit the editor, this will put the menu on focus.

    2. Press Ctrl-T, to put focus on the table. Use m to change the navigation mode, that can be cell, row or column. You can use vi-like keybindings h, j, k, l to navigate the table. Press q, to exit the table, this will put the menu on focus.

    3. The status bar should containt useful informations about the editor and/or the table

  • Structure: Has 3 panes, to show the tables and the columns and constraints of a selected table.

    1. Press d following of j, k to navigate the database tables. Hit enter to select one of the tables, informations about that table will be queried and should be visible in the other 2 panes.

    2. Press c or i to focus on the other panes. You can use the vi-like keys to navigate.

  • Quit: Quits the application

Comands

Is possible to call commands by pressing : while using the editor in normal mode. The commands available are:

  • import <str>: imports a file
  • export <str>: exports a file
  • enable <item> <bool>: enable/disable a item of configuration. Only numbers is available for now.
  • time: give the current time in some timezone
  • utc <timestr>: receives a time in string format and returns a time in utc
  • yank <str>: copy a string to the yank buffer of the editor
  • add <num> <num>: add 2 numbers
  • sub <num> <num>: subtract 2 numbers
  • table-get <row> <col>: yank a cell, row ou column of the table. row and col are either a number or a '-' (dash).
  • select-for <str>: receives a table name and generate a select statement for it
  • insert-for <str>: receives a table name and generate a insert statement for it

You can compose commands by using a pipe syntax. So the following expression copies the current time, in utc, to the yank buffer: time | utc | yank.

Tricks

In the connection page you can use Tab, Ctrl-J, Ctrl-K, Ctrl-L, Ctrl-H to move between the form fields

In the execute page, with the menu on focus you can press 0 or 9 to set the focus on the editor or the table. These keys and q can speed your life in this application.

Documentation

Overview

Demo code for the Grid primitive.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL