INNER CODE UNIT · Go

modeRequiresBranch

umputun/ralphex · cmd/ralphex/main.go:937

func modeRequiresBranch(mode processor.Mode) bool {
	return mode == processor.ModeFull || mode == processor.ModeTasksOnly
}

// makePauseHandler returns a context-aware pause handler for task loop breaks.
// on break, prints a message and waits for Enter to resume or context cancellation to abort.
// stdin read runs in a goroutine so the handler responds to Ctrl+C (SIGINT) promptly.
func makePauseHandler(stdin io.Reader, stdout io.Writer) func(ctx context.Context) bool {
	return func(ctx context.Context) bool {
		fmt.Fprintln(stdout, "\nsession interrupted. press Enter to continue, Ctrl+C to abort")

		resultCh := make(chan bool, 1)
		go func() {
			buf := make([]byte, 1)
			n, _ := stdin.Read(buf) // blocks until Enter or EOF
			resultCh <- n > 0       // true = Enter (resume), false = EOF (abort)
		}()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…