func executeShow(arguments map[string]interface{}, env *environments.Environment) { slice, err := slices.ExtractSlice( arguments["<lastNcommands>"], arguments["<startFromNCommand>"], arguments["<finishByMCommand>"]) if err != nil { utils.Logger.Panic(err) } var filter *utils.Regexp if arguments["--grep"] != nil { query := arguments["--grep"].(string) if arguments["--fuzzy"].(bool) { regex := new(bytes.Buffer) for _, character := range query { regex.WriteString(".*?") regex.WriteString(regexp.QuoteMeta(string(character))) } regex.WriteString(".*?") query = regex.String() } filter = utils.CreateRegexp(query) } utils.Logger.WithFields(logrus.Fields{ "slice": slice, "filter": filter, }).Info("Arguments of 'show'") commands.Show(slice, filter, env) }
package historyentries import ( "bufio" "strconv" "strings" logrus "github.com/Sirupsen/logrus" "github.com/9seconds/ah/app/environments" "github.com/9seconds/ah/app/utils" ) var ( bashTimestampRegexp = utils.CreateRegexp(`^#\s*\d+$`) zshLineRegexp = utils.CreateRegexp(`^: (\d+):\d;(.*?)$`) fishCmdRegexp = utils.CreateRegexp(`^- cmd:\s*(.*?)$`) fishWhenRegexp = utils.CreateRegexp(`\s*when:\s*(\d+)$`) ) type ( // Parser is a signature for a function which parses file and returns a Keeper. Parser func(Keeper, *bufio.Scanner, *utils.Regexp, chan *HistoryEntry) (Keeper, error) // ShellSpecificParser is a signature for a function which implements shell specific logic for parsing. ShellSpecificParser func(Keeper, string, uint, *HistoryEntry, *utils.Regexp, chan *HistoryEntry) (bool, uint, *HistoryEntry) ) func getParser(env *environments.Environment) Parser {
-m TMPDIR, --tmpdir=TMPDIR A temporary place where ah stores an output. Set it only if you need it. -g PATTERN, --grep PATTERN A pattern to filter command lines. It is regular expression if no -f option is set. -y, --tty Allocates pseudo-tty is necessary. -x, --run-in-real-shell Runs a command in real interactive shell. -z, --fuzzy Interpret -g pattern as fuzzy match string. -v, --debug Shows a debug log of command execution.` const version = "ah 0.14.2" var validateBookmarkName = utils.CreateRegexp(`^[A-Za-z_]\w*$`) type executor func(map[string]interface{}, *environments.Environment) func main() { defer func() { if exc := recover(); exc != nil { utils.Logger.Fatal(exc) } }() arguments, err := docopt.Parse(docoptOptions, nil, true, version, false) if err != nil { panic(err) }