cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2017 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package cli represents command line interface of mongoeye.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(config *Config) (info mgo.BuildInfo, session *mgo.Session, collection *mgo.Collection, err error)

Connect to MongoDB database and returns server info and session.

func Format

func Format(result Result, config *Config) ([]byte, error)

Format result of analysis.

func InitFlags

func InitFlags(cmd *cobra.Command, v *viper.Viper, envPrefix string)

InitFlags initializes flags and their default values

func NewCmd

func NewCmd(cmdName string, envPrefix string, appName string, appVersion string, appSubtitle string) (*cobra.Command, *viper.Viper)

NewCmd creates new root command.

func PreRun

func PreRun(cmd *cobra.Command, v *viper.Viper, osArgs []string, args []string) error

PreRun prints help, version and validate arguments.

func Run

func Run(cmd *cobra.Command, config *Config) error

Run command.

func RunWithSpinner

func RunWithSpinner(out io.Writer, msg string, task func())

RunWithSpinner allows run task with showing the spinner.

Types

type Config

type Config struct {
	// connection options
	ConnectionMode    mgo.Mode
	ConnectionTimeout time.Duration
	SyncTimeout       time.Duration
	SocketTimeout     time.Duration
	Host              string
	User              string
	Password          string
	AuthDatabase      string
	AuthMechanism     string

	// analysis options
	Database   string
	Collection string
	Query      bson.M
	Scope      string
	Limit      uint64
	Depth      uint

	// statistics options
	MinMaxAvgValue       bool
	MinMaxAvgLength      bool
	ValueHistogram       bool
	ValueHistogramSteps  uint
	LengthHistogram      bool
	LengthHistogramSteps uint
	WeekdayHistogram     bool
	HourHistogram        bool
	CountUnique          bool
	MostFrequentValues   uint
	LeastFrequentValues  uint
	Format               string
	FilePath             string

	// other options
	Location        *time.Location
	UseAggregation  bool
	StringMaxLength uint
	ArrayMaxLength  uint
	Concurrency     uint
	BufferSize      uint
	BatchSize       uint
	NoColor         bool
}

Config - app configuration.

func GetConfig

func GetConfig(v *viper.Viper) (*Config, error)

GetConfig - returns configuration according Viper values.

func (*Config) CreateAnalysisOptions

func (c *Config) CreateAnalysisOptions() *analysis.Options

CreateAnalysisOptions generates analysis options from config.

func (*Config) CreateExpandStageOptions

func (c *Config) CreateExpandStageOptions() *expand.Options

CreateExpandStageOptions generates expand options from config.

func (*Config) CreateGroupStageOptions

func (c *Config) CreateGroupStageOptions() *group.Options

CreateGroupStageOptions generates group options from config.

func (*Config) CreateMergeStageOptions

func (c *Config) CreateMergeStageOptions() *merge.Options

CreateMergeStageOptions generates merge options from config.

func (*Config) CreateSampleStageOptions

func (c *Config) CreateSampleStageOptions() *sample.Options

CreateSampleStageOptions generates sample options from config.

type FlagSection

type FlagSection struct {
	Name string
	Set  *pflag.FlagSet
}

FlagSection consists from section name and flags

type Flags

type Flags struct {
	Sections []*FlagSection
}

Flags consist from multiple sections

func (*Flags) AddSection

func (f *Flags) AddSection(name string) *FlagSection

AddSection adds new section to flags

func (*Flags) ExportAll

func (f *Flags) ExportAll(all *pflag.FlagSet)

ExportAll exports flags from all sections

func (*Flags) Usage

func (f *Flags) Usage() string

Usage generates usage information of flags.

type Result

type Result struct {
	Plan         string          `json:"plan"             yaml:"plan"`
	Duration     time.Duration   `json:"duration"         yaml:"duration"`
	AllDocsCount uint64          `json:"allDocsCount"     yaml:"allDocsCount"`
	DocsCount    uint64          `json:"docsCount"        yaml:"docsCount"`
	FieldsCount  uint64          `json:"fieldsCount"      yaml:"fieldsCount"`
	Fields       analysis.Fields `json:"fields"           yaml:"fields"`
}

Result of analysis.

type TableFormatter

type TableFormatter struct {
	// contains filtered or unexported fields
}

TableFormatter contains the data needed to draw the results as a table.

func NewTableFormatter

func NewTableFormatter(colorOutput bool) *TableFormatter

NewTableFormatter creates TableFormatter.

func (*TableFormatter) RenderResults

func (f *TableFormatter) RenderResults(result *Result) []byte

RenderResults renders results of analysis as a table.

Jump to

Keyboard shortcuts

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