mdqi

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: MIT Imports: 15 Imported by: 0

README

CircleCI

mdqi

mdqi is interactive interface for mdq. It supports:

  • Display query results with table based layout
  • Query history
  • Remember tag

Demo

demo

Recorded by asciinema.

Installation

Download binary from releases and put it on $PATHed place.

Or

$ go get github.com/handlename/mdqi/cmd/mdqi

Usage

$ mdqi
> select * from items;

TODO

Licence

MIT

Author

handlename

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSlashCommandNotFound    = errors.New("unknown SlashCommand")
	ErrNotASlashCommand        = errors.New("there are no SlashCommand")
	ErrSlashCommandInvalidArgs = errors.New("invalid args")
	ErrUnknownPrinterName      = errors.New("unknown printer name")
)
View Source
var Debug = func() *log.Logger {
	var out io.Writer

	if os.Getenv("DEBUG") != "" {
		out = os.Stderr
	} else {
		out = ioutil.Discard
	}

	l := log.New(out, "[debug] ", log.Ldate|log.Ltime|log.Lshortfile)

	return l
}()
View Source
var DefaultOutput io.Writer
View Source
var Logger = func() *log.Logger {
	return log.New(os.Stderr, "", log.Ldate|log.Ltime)
}()
View Source
var Version string

Functions

func ExpandPath added in v0.0.3

func ExpandPath(path string) (string, error)

ExpandPath expands file path like `~/path/to/foo`

func Fprint

func Fprint(out io.Writer, printer Printer, results []Result) error

func Print

func Print(printer Printer, results []Result) error

Types

type App

type App struct {
	// Alive turns into false, mdqi will exit.
	Alive bool

	// Printer prints results.
	Printer Printer
	// contains filtered or unexported fields
}

func NewApp

func NewApp(conf Conf) (*App, error)

func (*App) ClearTag

func (app *App) ClearTag()

func (*App) FindSlashCommandDefinition

func (app *App) FindSlashCommandDefinition(category, name string) (SlashCommandDefinition, error)

func (*App) GetTag

func (app *App) GetTag() string

func (*App) RegisterSlashCommandDefinition

func (app *App) RegisterSlashCommandDefinition(d SlashCommandDefinition) error

func (*App) Run

func (app *App) Run()

func (*App) RunCmd

func (app *App) RunCmd(query string, args ...string) (results []Result, err error)

func (*App) SetPrinterByName

func (app *App) SetPrinterByName(name string) error

func (*App) SetTag

func (app *App) SetTag(tag string)

func (*App) SlashCommandCategories added in v0.0.3

func (app *App) SlashCommandCategories() []string

func (*App) SlashCommandNames added in v0.0.3

func (app *App) SlashCommandNames(category string) []string

type Conf

type Conf struct {
	// Mdq contains configurations about mdq.
	Mdq ConfMdq `yaml:"mdq"`

	// Mdqi contains configurations about mdqi.
	Mdqi ConfMdqi `yaml:"mdqi"`
}

func ConfFromFile

func ConfFromFile(path string) (Conf, error)

type ConfMdq

type ConfMdq struct {
	// Bin is the path to mdq command.
	Bin string `yaml:"bin"`

	// Config is the path to configuration file for mdq.
	Config string `yaml:"config"`
}

type ConfMdqi

type ConfMdqi struct {
	// History is the path to history file.
	// Default value is "$HOME/.mdqi_history".
	History string `yaml:"history"`

	// DefaultTag is default value for mdq's --tag option.
	DefaultTag string `yaml:"default_tag"`

	// DefaultDisplay is default value for mdqi's /display command.
	DefaultDisplay string `yaml:"default_display"`
}

type HorizontalPrinter

type HorizontalPrinter struct{}

func (HorizontalPrinter) Name

func (p HorizontalPrinter) Name() string

func (HorizontalPrinter) Print

func (p HorizontalPrinter) Print(out io.Writer, results []Result) error

type Printer

type Printer interface {
	Name() string
	Print(out io.Writer, results []Result) error
}

type Result

type Result struct {
	Database string
	Columns  []string
	Rows     []map[string]interface{}
}

type SlashCommand

type SlashCommand struct {
	Category string
	Name     string
	Args     []string
}

func ParseSlashCommand

func ParseSlashCommand(query string) (*SlashCommand, error)

type SlashCommandDefinition

type SlashCommandDefinition interface {
	Category() string
	Name() string
	Example() string
	Help() string
	Handle(app *App, cmd *SlashCommand) error
}

type VerticalPrinter

type VerticalPrinter struct{}

func (VerticalPrinter) Name

func (p VerticalPrinter) Name() string

func (VerticalPrinter) Print

func (p VerticalPrinter) Print(out io.Writer, results []Result) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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