zrcadlo
https://github.com/quitesimpleorg/hs9001.git
synchronizováno 2025-01-19 03:51:26 +01:00
Porovnat revize
4 Commity
216e59747c
...
b9e3a3629b
Autor | SHA1 | Datum | |
---|---|---|---|
|
b9e3a3629b | ||
|
16752411e1 | ||
|
c480519fca | ||
|
70e66f47ba |
15
main.go
15
main.go
@ -234,7 +234,7 @@ func exists(path string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printUsage() {
|
func printUsage() {
|
||||||
fmt.Fprintf(os.Stderr, "Usage: ./hs9001 <add/search/import>\n")
|
fmt.Fprintf(os.Stderr, "Usage: ./hs9001 <add/search/import/nolog>\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -266,6 +266,8 @@ func main() {
|
|||||||
migrateDatabase(conn, fetchDBVersion(conn))
|
migrateDatabase(conn, fetchDBVersion(conn))
|
||||||
|
|
||||||
switch cmd {
|
switch cmd {
|
||||||
|
case "nolog":
|
||||||
|
fmt.Printf("Run this command to disable logging for the current shell:\n\tunset PROMPT_COMMAND\n")
|
||||||
case "add":
|
case "add":
|
||||||
var ret int
|
var ret int
|
||||||
addCmd.IntVar(&ret, "ret", 0, "Return value of the command to add")
|
addCmd.IntVar(&ret, "ret", 0, "Return value of the command to add")
|
||||||
@ -280,7 +282,7 @@ func main() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
historycmd := args[0]
|
historycmd := args[0]
|
||||||
var rgx = regexp.MustCompile("\\s+\\d+\\s+(.*)")
|
var rgx = regexp.MustCompile(`\s+\d+\s+(.*)`)
|
||||||
rs := rgx.FindStringSubmatch(historycmd)
|
rs := rgx.FindStringSubmatch(historycmd)
|
||||||
if len(rs) == 2 {
|
if len(rs) == 2 {
|
||||||
add(conn, NewHistoryEntry(rs[1], ret))
|
add(conn, NewHistoryEntry(rs[1], ret))
|
||||||
@ -293,7 +295,7 @@ func main() {
|
|||||||
var endTime string
|
var endTime string
|
||||||
var distinct bool = true
|
var distinct bool = true
|
||||||
var retVal int
|
var retVal int
|
||||||
searchCmd.StringVar(&workDir, "workdir", "%", "Search only within this workdir")
|
searchCmd.StringVar(&workDir, "cwd", "%", "Search only within this workdir")
|
||||||
searchCmd.StringVar(&beginTime, "begin", "50 years ago", "Start searching from this timeframe")
|
searchCmd.StringVar(&beginTime, "begin", "50 years ago", "Start searching from this timeframe")
|
||||||
searchCmd.StringVar(&endTime, "end", "now", "End searching from this timeframe")
|
searchCmd.StringVar(&endTime, "end", "now", "End searching from this timeframe")
|
||||||
searchCmd.BoolVar(&distinct, "distinct", true, "Remove consecutive duplicate commands from output")
|
searchCmd.BoolVar(&distinct, "distinct", true, "Remove consecutive duplicate commands from output")
|
||||||
@ -314,6 +316,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
q := strings.Join(args, " ")
|
q := strings.Join(args, " ")
|
||||||
|
if workDir != "%" {
|
||||||
|
workDir, err = filepath.Abs(workDir)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Failed parse working directory path: %s\n", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
results := search(conn, "%"+q+"%", workDir, beginTimestamp, endTimeStamp, retVal)
|
results := search(conn, "%"+q+"%", workDir, beginTimestamp, endTimeStamp, retVal)
|
||||||
|
|
||||||
previousCmd := ""
|
previousCmd := ""
|
||||||
|
Načítá se…
x
Odkázat v novém úkolu
Zablokovat Uživatele