summaryrefslogtreecommitdiff
path: root/internal/app/siftool/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/app/siftool/app.go')
-rw-r--r--internal/app/siftool/app.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/internal/app/siftool/app.go b/internal/app/siftool/app.go
index 1a7014c..8cc6377 100644
--- a/internal/app/siftool/app.go
+++ b/internal/app/siftool/app.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2021, Sylabs Inc. All rights reserved.
+// Copyright (c) 2021-2022, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE file distributed with the sources of this project regarding your
// rights to use or distribute this software.
@@ -13,6 +13,7 @@ import (
// appOpts contains configured options.
type appOpts struct {
out io.Writer
+ err io.Writer
}
// AppOpt are used to configure optional behavior.
@@ -31,11 +32,23 @@ func OptAppOutput(w io.Writer) AppOpt {
}
}
+// OptAppError specifies that errors should be written to w.
+func OptAppError(w io.Writer) AppOpt {
+ return func(o *appOpts) error {
+ o.err = w
+ return nil
+ }
+}
+
// New creates a new App configured with opts.
+//
+// By default, application output and errors are written to os.Stdout and os.Stderr respectively.
+// To modify this behavior, consider using OptAppOutput and/or OptAppError.
func New(opts ...AppOpt) (*App, error) {
a := App{
opts: appOpts{
out: os.Stdout,
+ err: os.Stderr,
},
}