Skip to content

Commit

Permalink
Rename to WithOnInterruptFunc for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
lammel committed Jun 12, 2023
1 parent 5cd27f2 commit 90505e9
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion interactive_confirm_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (p InteractiveConfirmPrinter) WithSuffixStyle(style *Style) *InteractiveCon
}

// OnInterrupt sets the function to execute on exit of the input reader
func (p InteractiveConfirmPrinter) OnInterrupt(exitFunc func()) *InteractiveConfirmPrinter {
func (p InteractiveConfirmPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveConfirmPrinter {
p.OnInterruptFunc = exitFunc
return &p
}
Expand Down
4 changes: 2 additions & 2 deletions interactive_confirm_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ func TestInteractiveConfirmPrinter_WithTextStyle(t *testing.T) {
testza.AssertEqual(t, p.TextStyle, style)
}

func TestInteractiveConfirmPrinter_OnInterrupt(t *testing.T) {
func TestInteractiveConfirmPrinter_WithOnInterruptFunc(t *testing.T) {
// OnInterrupt function defaults to nil
pd := pterm.InteractiveConfirmPrinter{}
testza.AssertNil(t, pd.OnInterruptFunc)

// Verify OnInterrupt is set
exitfunc := func() {}
p := pterm.DefaultInteractiveConfirm.OnInterrupt(exitfunc)
p := pterm.DefaultInteractiveConfirm.WithOnInterruptFunc(exitfunc)
testza.AssertEqual(t, reflect.ValueOf(p.OnInterruptFunc).Pointer(), reflect.ValueOf(exitfunc).Pointer())
}
2 changes: 1 addition & 1 deletion interactive_multiselect_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (p InteractiveMultiselectPrinter) WithCheckmark(checkmark *Checkmark) *Inte
}

// OnInterrupt sets the function to execute on exit of the input reader
func (p InteractiveMultiselectPrinter) OnInterrupt(exitFunc func()) *InteractiveMultiselectPrinter {
func (p InteractiveMultiselectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveMultiselectPrinter {
p.OnInterruptFunc = exitFunc
return &p
}
Expand Down
4 changes: 2 additions & 2 deletions interactive_multiselect_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func TestInteractiveMultiselectPrinter_WithCheckmark(t *testing.T) {
testza.AssertEqual(t, p.Checkmark, &pterm.Checkmark{Checked: "+", Unchecked: "-"})
}

func TestInteractiveMultiselectPrinter_OnInterrupt(t *testing.T) {
func TestInteractiveMultiselectPrinter_WithOnInterruptFunc(t *testing.T) {
// OnInterrupt function defaults to nil
pd := pterm.InteractiveMultiselectPrinter{}
testza.AssertNil(t, pd.OnInterruptFunc)

// Verify OnInterrupt is set
exitfunc := func() {}
p := pterm.DefaultInteractiveMultiselect.OnInterrupt(exitfunc)
p := pterm.DefaultInteractiveMultiselect.WithOnInterruptFunc(exitfunc)
testza.AssertEqual(t, reflect.ValueOf(p.OnInterruptFunc).Pointer(), reflect.ValueOf(exitfunc).Pointer())
}
2 changes: 1 addition & 1 deletion interactive_select_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelec
}

// OnInterrupt sets the function to execute on exit of the input reader
func (p InteractiveSelectPrinter) OnInterrupt(exitFunc func()) *InteractiveSelectPrinter {
func (p InteractiveSelectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveSelectPrinter {
p.OnInterruptFunc = exitFunc
return &p
}
Expand Down
4 changes: 2 additions & 2 deletions interactive_select_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func TestInteractiveSelectPrinter_WithMaxHeight(t *testing.T) {
testza.AssertEqual(t, p.MaxHeight, 1337)
}

func TestInteractiveSelectPrinter_OnInterrupt(t *testing.T) {
func TestInteractiveSelectPrinter_WithOnInterruptFunc(t *testing.T) {
// OnInterrupt function defaults to nil
pd := pterm.InteractiveSelectPrinter{}
testza.AssertNil(t, pd.OnInterruptFunc)

// Verify OnInterrupt is set
exitfunc := func() {}
p := pterm.DefaultInteractiveSelect.OnInterrupt(exitfunc)
p := pterm.DefaultInteractiveSelect.WithOnInterruptFunc(exitfunc)
testza.AssertEqual(t, reflect.ValueOf(p.OnInterruptFunc).Pointer(), reflect.ValueOf(exitfunc).Pointer())
}
2 changes: 1 addition & 1 deletion interactive_textinput_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p InteractiveTextInputPrinter) WithMask(mask string) *InteractiveTextInput
}

// OnInterrupt sets the function to execute on exit of the input reader
func (p InteractiveTextInputPrinter) OnInterrupt(exitFunc func()) *InteractiveTextInputPrinter {
func (p InteractiveTextInputPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveTextInputPrinter {
p.OnInterruptFunc = exitFunc
return &p
}
Expand Down
4 changes: 2 additions & 2 deletions interactive_textinput_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ func TestInteractiveTextInputPrinter_WithMask(t *testing.T) {
testza.AssertEqual(t, result, "abc")
}

func TestInteractiveTextInputPrinter_OnInterrupt(t *testing.T) {
func TestInteractiveTextInputPrinter_WithOnInterruptFunc(t *testing.T) {
// OnInterrupt function defaults to nil
pd := pterm.InteractiveTextInputPrinter{}
testza.AssertNil(t, pd.OnInterruptFunc)

// Verify OnInterrupt is set
exitfunc := func() {}
p := pterm.DefaultInteractiveTextInput.OnInterrupt(exitfunc)
p := pterm.DefaultInteractiveTextInput.WithOnInterruptFunc(exitfunc)
testza.AssertEqual(t, reflect.ValueOf(p.OnInterruptFunc).Pointer(), reflect.ValueOf(exitfunc).Pointer())
}

0 comments on commit 90505e9

Please sign in to comment.