cmd

package
v0.0.0-...-a578f59 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2018 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Copyright 2017 bee authors

Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// Header ...
	Header = `` /* 127-byte string literal not displayed */

	// Footer ...
	Footer = `` /* 148-byte string literal not displayed */

)
View Source
const (
	// MigrationMainTPL migration main template
	MigrationMainTPL = `` /* 647-byte string literal not displayed */

	// MYSQLMigrationDDL MySQL migration SQL
	MYSQLMigrationDDL = `` /* 622-byte string literal not displayed */

	// POSTGRESMigrationDDL Postgres migration SQL
	POSTGRESMigrationDDL = `` /* 286-byte string literal not displayed */

)
View Source
const (
	// BaleHeader ...
	BaleHeader = `` /* 848-byte string literal not displayed */

)

Variables

View Source
var AvailableCommands = []*Command{

	cmdNew,
	cmdRun,
	cmdPack,
	cmdApi,
	cmdRiot,
	cmdGse,

	cmdBale,
	cmdVersion,

	cmdMigrate,
	cmdFix,
}

Functions

func AutoBuild

func AutoBuild(files []string, isgenerate bool)

AutoBuild builds the specified set of files

func CloseFile

func CloseFile(f *os.File)

CloseFile attempts to close the passed file or panics with the actual error

func Colorize

func Colorize(text string, status string) string

func CopyFile

func CopyFile(src, dst string)

func EgoFuncMap

func EgoFuncMap() template.FuncMap

EgoFuncMap returns a FuncMap of functions used in different templates.

func GetGOPATHs

func GetGOPATHs() []string

GetGOPATHs returns all paths in GOPATH variable.

func Go

func Go(f func() error) chan error

Go is a basic promise implementation: it wraps calls a function in a goroutine and returns a channel which will later return the function's return value.

func Help

func Help(args []string)

func InitBanner

func InitBanner(out io.Writer, in io.Reader)

InitBanner loads the banner and prints it to output All errors are ignored, the application will not print the banner in case of error.

func IsEgoProject

func IsEgoProject(thePath string) bool

IsEgoProject checks whether the current path is a Egogo application or not

func IsGenerateDocs

func IsGenerateDocs(name string, args []string) bool

func IsInGOPATH

func IsInGOPATH(thePath string) bool

IsInGOPATH checks the path is in the fisrt GOPATH(/src) or not

func Kill

func Kill()

Kill kills the running command process

func MustCheck

func MustCheck(err error)

MustCheck panics when the error is not nil

func NewWatcher

func NewWatcher(paths []string, files []string, isgenerate bool)

NewWatcher starts an fsnotify Watcher on the specified paths

func Now

func Now(layout string) string

Now returns the current local time in the specified layout

func PrintErrorAndExit

func PrintErrorAndExit(message string)

func Restart

func Restart(appname string)

Restart kills the running command process and starts it again

func SearchGOPATHs

func SearchGOPATHs(app string) (bool, string, string)

SearchGOPATHs searches the user GOPATH(s) for the specified application name. It returns a boolean, the application's GOPATH and its full path.

func ShowShortVersionBanner

func ShowShortVersionBanner()

ShowShortVersionBanner prints the short version banner.

func ShowVerboseVersionBanner

func ShowVerboseVersionBanner()

ShowVerboseVersionBanner prints the verbose version banner

func Start

func Start(appname string)

Start starts the command process

func TmplToString

func TmplToString(tmpl string, data interface{}) string

TmplToString parses a text template and return the result as a string.

func Usage

func Usage()

func WriteToFile

func WriteToFile(filename, content string)

WriteToFile creates a file and writes content to it

func Writefile

func Writefile(fileName, writeStr string)

Types

type Annotation

type Annotation struct {
	Pos, End   int16
	Kind       AnnotationKind
	ImportPath string
}

type AnnotationKind

type AnnotationKind int16
const (
	ExportLinkAnnotation AnnotationKind = iota
	AnchorAnnotation
	CommentAnnotation
	PackageLinkAnnotation
	BuiltinAnnotation
)

type ByteWriter

type ByteWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

ByteWriter ...

func (*ByteWriter) Write

func (w *ByteWriter) Write(p []byte) (n int, err error)

type Code

type Code struct {
	Text        string
	Annotations []Annotation
}

type Command

type Command struct {
	// Run runs the command.
	// The args are the arguments after the command name.
	Run func(cmd *Command, args []string) int

	// PreRun performs an operation before running the command
	PreRun func(cmd *Command, args []string)

	// UsageLine is the one-line usage message.
	// The first word in the line is taken to be the command name.
	UsageLine string

	// Short is the short description shown in the 'go help' output.
	Short string

	// Long is the long message shown in the 'go help <this-command>' output.
	Long string

	// Flag is a set of flags specific to this command.
	Flag flag.FlagSet

	// CustomFlags indicates that the command will do its own
	// flag parsing.
	CustomFlags bool
	// contains filtered or unexported fields
}

Command is the unit of execution

func (*Command) Name

func (c *Command) Name() string

Name returns the command's name: the first word in the usage line.

func (*Command) Options

func (c *Command) Options() map[string]string

func (*Command) Out

func (c *Command) Out() io.Writer

Out returns the out writer of the current command. If cmd.output is nil, os.Stderr is used.

func (*Command) Runnable

func (c *Command) Runnable() bool

Runnable reports whether the command can be run; otherwise it is a documentation pseudo-command such as import path.

func (*Command) SetOutput

func (c *Command) SetOutput(output io.Writer)

SetOutput sets the destination for usage and error messages. If output is nil, os.Stderr is used.

func (*Command) Usage

func (c *Command) Usage()

Usage puts out the usage for the command.

type ListOpts

type ListOpts []string

func (*ListOpts) Set

func (opts *ListOpts) Set(value string) error

func (*ListOpts) String

func (opts *ListOpts) String() string

type RuntimeInfo

type RuntimeInfo struct {
	GoVersion  string
	GOOS       string
	GOARCH     string
	NumCPU     int
	GOPATH     string
	GOROOT     string
	Compiler   string
	EVersion   string
	EgoVersion string
}

RuntimeInfo holds information about the current runtime.

Jump to

Keyboard shortcuts

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