coach

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: MIT Imports: 17 Imported by: 0

README

Coach Build Status

Coach helps you maximize you and your team's performance on the command line.

Install

go get -u github.com/alittlebrighter/coach/cmd/coach

To use coach to monitor your command line usage, add the following to your .bashrc file:

function prompt {
    coach history --record "$(history 1)"
}

PROMPT_COMMAND=prompt

There is currently no way to track command history in any other shell (I'm open to ideas on how to resolve that).

Usage

Once you've started a new session just continue using your terminal as you normally would and coach will prompt you to save frequently run commands. Terminal Usage

To add more lines you can run:

$ coach doc -e get-weather

and coach will pull up your script along with its metadata inside of the editor specified by $EDITOR Edit Script Just save and quit to keep your changes in coach.

Run coach --help to see other available options.

Docs

Until I get proper documentation up for now you can use the following:

  • coach - run coach --help
  • coach-grpc-server - the .proto files that the gRPC service implements can be found in the protobuf directory. There are some comments there but further documentation will be provided once I have an interface to plug in security components.
  • coach-grpc-web - documentation waiting on security components

Roadmap

  • interfaces to add authentication via Go plugins
  • authorization
  • interface to allow launching deeper analysis of command history

Contributing

  1. Fork it
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create new Pull Request

Documentation

Index

Constants

View Source
const Header = "exported from COACH - https://github.com/alittlebrighter/coach"

Variables

View Source
var (
	DBPath string
)

Functions

func DeleteScript added in v1.2.0

func DeleteScript(alias string, store ScriptStore) error

func EditScript

func EditScript(alias string, store ScriptStore) (*models.DocumentedScript, error)

func GetRecentHistory

func GetRecentHistory(n int, allSessions bool, store HistoryGetter) (lines []models.HistoryRecord, err error)

func GetStore added in v1.2.0

func GetStore(readonly bool) *database.BoltDB

TODO: this needs to return an interface

func IgnoreCommand added in v1.2.0

func IgnoreCommand(command string, store IgnoreStore) error

func IgnoreHistory added in v1.2.0

func IgnoreHistory(lineCount int, allVariations, remove bool, store IgnoreStore) error

func ImportHistory added in v1.2.0

func ImportHistory(store HistoryStore) error

func MarshalEdit

func MarshalEdit(s models.DocumentedScript) []byte

func QueryHistory added in v1.3.0

func QueryHistory(regex string, all bool, store HistoryStore) (lines []models.HistoryRecord, err error)

func QueryScripts

func QueryScripts(query string, store ScriptStore) (scripts []models.DocumentedScript, err error)

func RandomID

func RandomID() (id []byte)

func RestoreScript added in v1.2.0

func RestoreScript(alias string, store ScriptStore) (*models.DocumentedScript, error)

func RunScript

func RunScript(ctx context.Context, script models.DocumentedScript, args []string, configureIO func(*exec.Cmd) error) error

func SaveHistory

func SaveHistory(line string, dupeCount int, store HistoryStore) (promptDoc bool, err error)

func SaveScript

func SaveScript(toSave models.DocumentedScript, overwrite bool, store ScriptStore) (err error)

func ShouldIgnore added in v1.2.0

func ShouldIgnore(command string, store IgnoreChecker) bool

func UnmarshalEdit

func UnmarshalEdit(contents, originalShell string) (ds models.DocumentedScript, err error)

func UnmarshalLine added in v1.2.0

func UnmarshalLine(line string, ds *models.DocumentedScript) (processed bool)

Types

type Closable added in v1.2.0

type Closable interface {
	Close() error
}

type HistoryGetter added in v1.2.0

type HistoryGetter interface {
	GetRecent(tty string, username string, n int) ([]models.HistoryRecord, error)
}

type HistoryStore

type HistoryStore interface {
	Save(id []byte, value interface{}, overwrite bool) error
	SaveBatch(<-chan database.HasID, []byte) <-chan error
	CheckDupeCmds(string, int) bool
	PruneHistory(max int) error
	QueryHistory(regex *regexp.Regexp, user string, all bool) ([]models.HistoryRecord, error)
	HistoryGetter
	IgnoreChecker
}

type IgnoreChecker added in v1.2.0

type IgnoreChecker interface {
	ShouldIgnoreCommand(command, username string) (yes bool)
	ShouldIgnoreWord(word, username string) (yes bool)
}

type IgnoreStore added in v1.2.0

type IgnoreStore interface {
	IgnoreWord(word, username string) (err error)
	UnignoreWord(word, username string) (err error)
	IgnoreCommand(command, username string) (err error)
	UnignoreCommand(command, username string) (err error)
	IgnoreChecker
	HistoryGetter
}

type ScriptStore

type ScriptStore interface {
	Save(id []byte, value interface{}, overwrite bool) error
	GetScript(id []byte) *models.DocumentedScript
	QueryScripts(...string) ([]models.DocumentedScript, error)
	DeleteScript(id []byte) error
	IgnoreStore
	Closable
}

Directories

Path Synopsis
cmd
gen
storage

Jump to

Keyboard shortcuts

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