Update godoc for the cmd package and subpackages

pull/7781/head
Mark Rushakoff 2016-12-28 15:15:31 -08:00
parent 623bb71b01
commit 6768c6ed3b
22 changed files with 44 additions and 21 deletions

View File

@ -1,3 +1,4 @@
// Package cli contains the logic of the influx command line client.
package cli // import "github.com/influxdata/influxdb/cmd/influx/cli"
import (
@ -34,7 +35,7 @@ const (
// ErrBlankCommand is returned when a parsed command is empty.
var ErrBlankCommand = errors.New("empty input")
// CommandLine holds CLI configuration and state
// CommandLine holds CLI configuration and state.
type CommandLine struct {
Line *liner.State
Host string
@ -61,7 +62,7 @@ type CommandLine struct {
ImporterConfig v8.Config // Importer configuration options.
}
// New returns an instance of CommandLine
// New returns an instance of CommandLine with the specified client version.
func New(version string) *CommandLine {
return &CommandLine{
ClientVersion: version,
@ -70,7 +71,7 @@ func New(version string) *CommandLine {
}
}
// Run executes the CLI
// Run executes the CLI.
func (c *CommandLine) Run() error {
hasTTY := c.ForceTTY || terminal.IsTerminal(int(os.Stdin.Fd()))
@ -221,7 +222,8 @@ func (c *CommandLine) mainLoop() error {
}
}
// ParseCommand parses an instruction and calls related method, if any
// ParseCommand parses an instruction and calls the related method
// or executes the command as a query against InfluxDB.
func (c *CommandLine) ParseCommand(cmd string) error {
lcmd := strings.TrimSpace(strings.ToLower(cmd))
tokens := strings.Fields(lcmd)
@ -270,7 +272,7 @@ func (c *CommandLine) ParseCommand(cmd string) error {
return ErrBlankCommand
}
// Connect connects client to a server
// Connect connects to a server.
func (c *CommandLine) Connect(cmd string) error {
// Remove the "connect" keyword if it exists
addr := strings.TrimSpace(strings.Replace(cmd, "connect", "", -1))
@ -312,7 +314,7 @@ func (c *CommandLine) Connect(cmd string) error {
return nil
}
// SetAuth sets client authentication credentials
// SetAuth sets client authentication credentials.
func (c *CommandLine) SetAuth(cmd string) {
// If they pass in the entire command, we should parse it
// auth <username> <password>
@ -482,7 +484,7 @@ func (c *CommandLine) retentionPolicyExists(db, rp string) bool {
return true
}
// SetPrecision sets client precision
// SetPrecision sets client precision.
func (c *CommandLine) SetPrecision(cmd string) {
// normalize cmd
cmd = strings.ToLower(cmd)
@ -502,7 +504,7 @@ func (c *CommandLine) SetPrecision(cmd string) {
}
}
// SetFormat sets output format
// SetFormat sets output format.
func (c *CommandLine) SetFormat(cmd string) {
// Remove the "format" keyword if it exists
cmd = strings.TrimSpace(strings.Replace(cmd, "format", "", -1))
@ -517,7 +519,7 @@ func (c *CommandLine) SetFormat(cmd string) {
}
}
// SetWriteConsistency sets cluster consistency level
// SetWriteConsistency sets write consistency level.
func (c *CommandLine) SetWriteConsistency(cmd string) {
// Remove the "consistency" keyword if it exists
cmd = strings.TrimSpace(strings.Replace(cmd, "consistency", "", -1))
@ -630,7 +632,7 @@ func (c *CommandLine) parseInsert(stmt string) (*client.BatchPoints, error) {
}, nil
}
// Insert runs an INSERT statement
// Insert runs an INSERT statement.
func (c *CommandLine) Insert(stmt string) error {
bp, err := c.parseInsert(stmt)
if err != nil {
@ -657,7 +659,7 @@ func (c *CommandLine) query(query string) client.Query {
}
}
// ExecuteQuery runs any query statement
// ExecuteQuery runs any query statement.
func (c *CommandLine) ExecuteQuery(query string) error {
// If we have a retention policy, we need to rewrite the statement sources
if c.RetentionPolicy != "" {
@ -699,7 +701,7 @@ func (c *CommandLine) ExecuteQuery(query string) error {
return nil
}
// DatabaseToken retrieves database token
// DatabaseToken retrieves database token.
func (c *CommandLine) DatabaseToken() (string, error) {
response, err := c.Client.Query(c.query("SHOW DIAGNOSTICS for 'registration'"))
if err != nil {
@ -719,7 +721,7 @@ func (c *CommandLine) DatabaseToken() (string, error) {
return "", nil
}
// FormatResponse formats output to previsouly chosen format
// FormatResponse formats output to the previously chosen format.
func (c *CommandLine) FormatResponse(response *client.Response, w io.Writer) {
switch c.Format {
case "json":
@ -874,7 +876,7 @@ func interfaceToString(v interface{}) string {
}
}
// Settings prints current settings
// Settings prints current settings.
func (c *CommandLine) Settings() {
w := new(tabwriter.Writer)
w.Init(os.Stdout, 0, 1, 1, ' ', 0)
@ -992,7 +994,7 @@ func (c *CommandLine) gopher() {
`)
}
// Version prints CLI version
// Version prints the CLI version.
func (c *CommandLine) Version() {
fmt.Println("InfluxDB shell version:", c.ClientVersion)
}

View File

@ -1,3 +1,4 @@
// The influx command is a CLI client to InfluxDB.
package main
import (

View File

@ -1,3 +1,4 @@
// Package dumptsm inspects low-level details about tsm1 files.
package dumptsm
import (

View File

@ -1,3 +1,4 @@
// Package export exports TSM files into InfluxDB line protocol format.
package export
import (

View File

@ -1,3 +1,4 @@
// Package help contains the help for the influx_inspect command.
package help
import (

View File

@ -1,3 +1,4 @@
// The influx_inspect command displays detailed information about InfluxDB data files.
package main
import (
@ -16,7 +17,6 @@ import (
)
func main() {
m := NewMain()
if err := m.Run(os.Args[1:]...); err != nil {
fmt.Fprintln(os.Stderr, err)
@ -33,7 +33,7 @@ type Main struct {
Stderr io.Writer
}
// NewMain return a new instance of Main.
// NewMain returns a new instance of Main.
func NewMain() *Main {
return &Main{
Logger: log.New(os.Stderr, "[influx_inspect] ", log.LstdFlags),

View File

@ -1,3 +1,4 @@
// Package report reports statistics about TSM files.
package report
import (

View File

@ -1,3 +1,4 @@
// Package verify verifies integrity of TSM files.
package verify
import (

View File

@ -1,3 +1,4 @@
// Command influx_stress is deprecated; use github.com/influxdata/influx-stress instead.
package main
import (

View File

@ -1,3 +1,4 @@
// Package b1 reads data from b1 shards.
package b1 // import "github.com/influxdata/influxdb/cmd/influx_tsm/b1"
import (

View File

@ -1,3 +1,4 @@
// Package bz1 reads data from bz1 shards.
package bz1 // import "github.com/influxdata/influxdb/cmd/influx_tsm/bz1"
import (

View File

@ -1,3 +1,5 @@
// Command influx_tsm converts b1 or bz1 shards (from InfluxDB releases earlier than v0.11)
// to the current tsm1 format.
package main
import (

View File

@ -1,3 +1,4 @@
// Package stats contains statistics for converting non-TSM shards to TSM.
package stats
import (

View File

@ -1,3 +1,4 @@
// Pacage tsdb abstracts the various shard types supported by the influx_tsm command.
package tsdb // import "github.com/influxdata/influxdb/cmd/influx_tsm/tsdb"
import (

View File

@ -1,3 +1,4 @@
// Package backup is the backup subcommand for the influxd command.
package backup
import (

View File

@ -1,3 +1,4 @@
// Package help is the help subcommand of the influxd command.
package help
import (

View File

@ -1,3 +1,4 @@
// Command influxd is the InfluxDB server.
package main
import (

View File

@ -1,3 +1,5 @@
// Package restore is the restore subcommand for the influxd command,
// for restoring from a backup.
package restore
import (

View File

@ -1,3 +1,4 @@
// Package run is the run (default) subcommand for the influxd command.
package run
import (
@ -186,7 +187,7 @@ func (cmd *Command) writePIDFile(path string) error {
}
// ParseConfig parses the config at path.
// Returns a demo configuration if path is blank.
// It returns a demo configuration if path is blank.
func (cmd *Command) ParseConfig(path string) (*Config, error) {
// Use demo configuration if no config path is specified.
if path == "" {
@ -204,7 +205,7 @@ func (cmd *Command) ParseConfig(path string) (*Config, error) {
return config, nil
}
var usage = `Runs the InfluxDB server.
const usage = `Runs the InfluxDB server.
Usage: influxd run [flags]

View File

@ -110,8 +110,8 @@ func NewDemoConfig() (*Config, error) {
}
// trimBOM trims the Byte-Order-Marks from the beginning of the file.
// this is for Windows compatability only.
// see https://github.com/influxdata/telegraf/issues/1378
// This is for Windows compatability only.
// See https://github.com/influxdata/telegraf/issues/1378.
func trimBOM(f []byte) []byte {
return bytes.TrimPrefix(f, []byte("\xef\xbb\xbf"))
}

View File

@ -201,6 +201,7 @@ func NewServer(c *Config, buildInfo *BuildInfo) (*Server, error) {
return s, nil
}
// Statistics returns statistics for the services running in the Server.
func (s *Server) Statistics(tags map[string]string) []models.Statistic {
var statistics []models.Statistic
statistics = append(statistics, s.QueryExecutor.Statistics(tags)...)

View File

@ -1,3 +1,4 @@
// Package cmd is the root package of the various command-line utilities for InfluxDB.
package cmd
import "strings"