Documentation
¶
Overview ¶
Package cli represents command line interface of mongoeye.
Index ¶
- func Connect(config *Config) (info mgo.BuildInfo, session *mgo.Session, collection *mgo.Collection, ...)
- func Format(result Result, config *Config) ([]byte, error)
- func InitFlags(cmd *cobra.Command, v *viper.Viper, envPrefix string)
- func NewCmd(cmdName string, envPrefix string, appName string, appVersion string, ...) (*cobra.Command, *viper.Viper)
- func PreRun(cmd *cobra.Command, v *viper.Viper, osArgs []string, args []string) error
- func Run(cmd *cobra.Command, config *Config) error
- func RunWithSpinner(out io.Writer, msg string, task func())
- type Config
- type FlagSection
- type Flags
- type Result
- type TableFormatter
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 NewCmd ¶
func NewCmd(cmdName string, envPrefix string, appName string, appVersion string, appSubtitle string) (*cobra.Command, *viper.Viper)
NewCmd creates new root command.
func RunWithSpinner ¶
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 (*Config) CreateAnalysisOptions ¶
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 ¶
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
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.