mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-26 15:02:00 +02:00
Restore stdin import for the hishtory import command
This commit is contained in:
parent
d255131d68
commit
ab7db995aa
@ -391,7 +391,7 @@ func CheckFatalError(err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImportHistory(ctx *context.Context) (int, error) {
|
func ImportHistory(ctx *context.Context, shouldReadStdin bool) (int, error) {
|
||||||
config := hctx.GetConf(ctx)
|
config := hctx.GetConf(ctx)
|
||||||
if config.HaveCompletedInitialImport {
|
if config.HaveCompletedInitialImport {
|
||||||
// Don't run an import if we already have run one. This avoids importing the same entry multiple times.
|
// Don't run an import if we already have run one. This avoids importing the same entry multiple times.
|
||||||
@ -407,11 +407,13 @@ func ImportHistory(ctx *context.Context) (int, error) {
|
|||||||
return 0, fmt.Errorf("failed to parse zsh history: %v", err)
|
return 0, fmt.Errorf("failed to parse zsh history: %v", err)
|
||||||
}
|
}
|
||||||
historyEntries = append(historyEntries, extraEntries...)
|
historyEntries = append(historyEntries, extraEntries...)
|
||||||
// extraEntries, err = readStdin()
|
if shouldReadStdin {
|
||||||
// if err != nil {
|
extraEntries, err = readStdin()
|
||||||
// return 0, fmt.Errorf("failed to read stdin: %v", err)
|
if err != nil {
|
||||||
// }
|
return 0, fmt.Errorf("failed to read stdin: %v", err)
|
||||||
// historyEntries = append(historyEntries, extraEntries...)
|
}
|
||||||
|
historyEntries = append(historyEntries, extraEntries...)
|
||||||
|
}
|
||||||
db := hctx.GetDb(ctx)
|
db := hctx.GetDb(ctx)
|
||||||
currentUser, err := user.Current()
|
currentUser, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -75,7 +75,7 @@ func main() {
|
|||||||
if os.Getenv("HISHTORY_TEST") == "" {
|
if os.Getenv("HISHTORY_TEST") == "" {
|
||||||
fmt.Println("Importing existing shell history...")
|
fmt.Println("Importing existing shell history...")
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
numImported, err := lib.ImportHistory(ctx)
|
numImported, err := lib.ImportHistory(ctx, false)
|
||||||
lib.CheckFatalError(err)
|
lib.CheckFatalError(err)
|
||||||
if numImported > 0 {
|
if numImported > 0 {
|
||||||
fmt.Printf("Imported %v history entries from your existing shell history\n", numImported)
|
fmt.Printf("Imported %v history entries from your existing shell history\n", numImported)
|
||||||
@ -83,7 +83,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
case "import":
|
case "import":
|
||||||
ctx := hctx.MakeContext()
|
ctx := hctx.MakeContext()
|
||||||
numImported, err := lib.ImportHistory(ctx)
|
numImported, err := lib.ImportHistory(ctx, true)
|
||||||
lib.CheckFatalError(err)
|
lib.CheckFatalError(err)
|
||||||
if numImported > 0 {
|
if numImported > 0 {
|
||||||
fmt.Printf("Imported %v history entries from your existing shell history\n", numImported)
|
fmt.Printf("Imported %v history entries from your existing shell history\n", numImported)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user