diff --git a/app.go b/app.go index a39c88b..d23589d 100644 --- a/app.go +++ b/app.go @@ -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 +} diff --git a/app_test.go b/app_test.go index b632b5d..8ad672d 100644 --- a/app_test.go +++ b/app_test.go @@ -370,3 +370,7 @@ func TestWaitFor(t *testing.T) { }) } } + +func TestNoApp(t *testing.T) { + require.Nil(t, lu.NoApp()) +}