forked from TrueCloudLab/frostfs-node
[#1714] lens: Separate commands
Separate `inspect` and `list` on `write-cache` and `blobovnicza` subcommands. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
387953c1e0
commit
adff08ad02
12 changed files with 316 additions and 222 deletions
31
cmd/neofs-lens/internal/errors.go
Normal file
31
cmd/neofs-lens/internal/errors.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Errf returns formatted error in errFmt format if err is not nil.
|
||||
func Errf(errFmt string, err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf(errFmt, err)
|
||||
}
|
||||
|
||||
// ExitOnErr calls exitOnErrCode with code 1.
|
||||
func ExitOnErr(cmd *cobra.Command, err error) {
|
||||
exitOnErrCode(cmd, err, 1)
|
||||
}
|
||||
|
||||
// exitOnErrCode prints error via cmd and calls os.Exit with passed exit code.
|
||||
// Does nothing if err is nil.
|
||||
func exitOnErrCode(cmd *cobra.Command, err error, code int) {
|
||||
if err != nil {
|
||||
cmd.PrintErrln(err)
|
||||
os.Exit(code)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue