mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-08 10:26:35 -06:00
exit noms as soon as less quits, not when stdout closes (#2068)
This commit is contained in:
@@ -51,16 +51,16 @@ func runDiff(args []string) int {
|
||||
}
|
||||
defer db2.Close()
|
||||
|
||||
waitChan := outputpager.PageOutput(!outputpager.NoPager)
|
||||
|
||||
waitChan := outputpager.PageOutput()
|
||||
w := bufio.NewWriter(os.Stdout)
|
||||
diff.Diff(w, value1, value2)
|
||||
fmt.Fprintf(w, "\n")
|
||||
w.Flush()
|
||||
|
||||
if waitChan != nil {
|
||||
os.Stdout.Close()
|
||||
<-waitChan
|
||||
go func() {
|
||||
<-waitChan
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
|
||||
diff.Diff(w, value1, value2)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func runLog(args []string) int {
|
||||
d.CheckErrorNoUsage(fmt.Errorf("Object not found: %s", args[0]))
|
||||
}
|
||||
|
||||
waitChan := outputpager.PageOutput(!outputpager.NoPager)
|
||||
waitChan := outputpager.PageOutput()
|
||||
|
||||
origCommit, ok := value.(types.Struct)
|
||||
if !ok || !origCommit.Type().Equals(datas.CommitType()) {
|
||||
|
||||
@@ -40,7 +40,7 @@ func runShow(args []string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
waitChan := outputpager.PageOutput(!outputpager.NoPager)
|
||||
waitChan := outputpager.PageOutput()
|
||||
|
||||
w := bufio.NewWriter(os.Stdout)
|
||||
types.WriteEncodedValueWithTags(w, value)
|
||||
|
||||
@@ -14,19 +14,19 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
NoPager bool
|
||||
noPager bool
|
||||
flagsRegistered = false
|
||||
)
|
||||
|
||||
func RegisterOutputpagerFlags(flags *flag.FlagSet) {
|
||||
if !flagsRegistered {
|
||||
flagsRegistered = true
|
||||
flags.BoolVar(&NoPager, "no-pager", false, "suppress paging functionality")
|
||||
flags.BoolVar(&noPager, "no-pager", false, "suppress paging functionality")
|
||||
}
|
||||
}
|
||||
|
||||
func PageOutput(usePager bool) <-chan struct{} {
|
||||
if !usePager || !IsStdoutTty() {
|
||||
func PageOutput() <-chan struct{} {
|
||||
if noPager || !IsStdoutTty() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user