gang

package module
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2015 License: MIT Imports: 15 Imported by: 0

README

gang

Gang is a command snippet tool on termnal.

screenshot

Installtion

Get the command:

$ go get github.com/ysugimoto/gang/cmd/gang

Usage

Show help:

$ gang -h
====================================================
 Gang - A console command snippet management tool
====================================================
Usage:
    gang [subcommand|snippet-name] [parameters...] [option]

Options:
    -h, --help      : Show this help
    -d, --directory : Change current directory
    -v, --version   : Show version number

Subcommands:
    mode [ls|peco]                  : Change list mode
    ammo                            : Show list sorted by call times
    kill [snippet-name]             : Remove snippet
    bullet [snippet-name] [command] : Register the snippet
    [snippet-name] [bind,...]       : Run the snippet command
  • gang mode [ls|peco]: change list mode.
    • ls: show command list and execute selected number's command.
    • peco: select command from peco, and execute.
  • ammo: sort by times whitch executed command, and show list.
  • kill: purge command snippet
  • bullet: regist new command snippet

Feature

Support placeholder

Gang supports placeholder snippet like {:name}, apply parameter dynamically on execute.

# Regist command with placeholder
$ gang bullet sample "echo \"{:word}\" | grep world"
> [gang] Command "sample" Bulleted.

# execute
$ gang sample
> [gang] Execute command needs parameter: echo "{:word}" | grep World
> [gang] Bind Parameter "word" is: World # input "World"
World

License

MIT

Author

Yoshiaki Sugimoto

Thanks

This tool was Insprired from:

Documentation

Index

Constants

View Source
const (
	MODE_LS   = "ls"
	MODE_PECO = "peco"

	SHELL_BASH = "bash"
	SHELL_ZSH  = "zsh"
)
View Source
const (
	SQ = 39
	DQ = 34
)
View Source
const (
	VERSION = "0.8.0"
)

Variables

View Source
var (
	RESET    = ansi.ColorCode("reset")
	RED      = ansi.ColorCode("red")
	REDB     = ansi.ColorCode("red+b")
	GREEN    = ansi.ColorCode("green")
	GREENB   = ansi.ColorCode("green+b")
	MAGENTA  = ansi.ColorCode("magenta")
	MAGENTAB = ansi.ColorCode("magenta+b")
	CYAN     = ansi.ColorCode("cyan")
	CYANB    = ansi.ColorCode("cyan+b")

	GANG = fmt.Sprint(MAGENTAB, "[gang] ", RESET)
)
View Source
var BIND = regexp.MustCompile("(\\{:([0-9a-zA-Z\\.@\\-_]+?)\\})")
View Source
var DOUBLE_SPACE = regexp.MustCompile("\\s{2,}")

Functions

func EPrint

func EPrint(message string)

func EPrintf

func EPrintf(format string, args ...interface{})

func EPrintln

func EPrintln(message string)

func ESprint

func ESprint(message string) string

func ESprintf

func ESprintf(format string, args ...interface{}) string

func GetInputOfSelectIndex

func GetInputOfSelectIndex(list []string) int

func GetInputOfYesNo

func GetInputOfYesNo(msg string) bool

func Print

func Print(message string)

func Printf

func Printf(format string, args ...interface{})

func Println

func Println(message string)

func QPrint

func QPrint(message string)

func QPrintf

func QPrintf(format string, args ...interface{})

func QPrintln

func QPrintln(message string)

func QSprint

func QSprint(message string) string

func QSprintf

func QSprintf(format string, args ...interface{}) string

func Scanf

func Scanf(format string, capture ...interface{}) (int, error)

func ShowHelp

func ShowHelp()

func Sprint

func Sprint(message string) string

func Sprintf

func Sprintf(format string, args ...interface{}) string

Types

type Command

type Command struct {
	Name  string `json:"name"`
	Cmd   string `json:"cmd"`
	Times int    `json:"times"`
}

func (*Command) Increment

func (c *Command) Increment()

func (Command) String

func (c Command) String(size int) string

type CommandList

type CommandList []Command

func (CommandList) Add

func (cl CommandList) Add(name, cmd string)

func (CommandList) Find

func (cl CommandList) Find(name string) *Command

func (CommandList) FindIndex

func (cl CommandList) FindIndex(index int) *Command

func (CommandList) GetMaxNameSize

func (cl CommandList) GetMaxNameSize() (max int)

func (CommandList) Kill

func (cl CommandList) Kill(name string) (killed bool)

func (CommandList) Len

func (cl CommandList) Len() int

func (CommandList) Less

func (cl CommandList) Less(i, j int) bool

func (CommandList) Swap

func (cl CommandList) Swap(i, j int)

type Config

type Config struct {
	ListMode string      `json:"listmode"`
	Shell    string      `json:"shell"`
	Commands CommandList `json:"commands"`
}

func (*Config) Save

func (c *Config) Save()

type Operation

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

func NewOperation

func NewOperation(conf *Config) *Operation

func (*Operation) RunBullet

func (o *Operation) RunBullet(name string, nameOk bool, cmd string, cmdOk bool) int

func (*Operation) RunCommand

func (o *Operation) RunCommand(cmd string) int

func (*Operation) RunDefault

func (o *Operation) RunDefault(cmd string) int

func (*Operation) RunKill

func (o *Operation) RunKill(name string) int

func (*Operation) RunList

func (o *Operation) RunList(list []string) int

func (*Operation) RunListMode

func (o *Operation) RunListMode(mode string) int

func (*Operation) RunShell

func (o *Operation) RunShell(command string) int

func (*Operation) RunShellMode

func (o *Operation) RunShellMode(shell string) int

type Runner

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

func NewRunner

func NewRunner(args *cliarg.Arguments) *Runner

func (*Runner) Run

func (r *Runner) Run()

type Shell

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

func NewShell

func NewShell(cmd string) *Shell

func (*Shell) Run

func (s *Shell) Run() ([]byte, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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