Skip to content

Commit

Permalink
Add NoApp()
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilLuno committed Oct 23, 2024
1 parent d4c4281 commit d9dfbf0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,10 @@ func handleShutdownErr(a *App, ac AppContext, err error) error {
}
return err
}

// NoApp returns a nil app.
// It can be used when you call a function that accepts a *App, but there's no lu app in scope.
// f(lu.NoApp()) reads more clearly than f(nil).
func NoApp() *App {
return nil
}
4 changes: 4 additions & 0 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,7 @@ func TestWaitFor(t *testing.T) {
})
}
}

func TestNoApp(t *testing.T) {
require.Nil(t, lu.NoApp())
}

0 comments on commit d9dfbf0

Please sign in to comment.