[#665] cli: Set non-zero exit codes in err cases

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-07-06 15:27:54 +03:00 committed by Leonard Lyubich
parent 8965e70463
commit 3a7d7bdecd
8 changed files with 245 additions and 742 deletions

View file

@ -63,9 +63,8 @@ var (
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
err := rootCmd.Execute()
exitOnErr(rootCmd, err)
}
func init() {
@ -136,10 +135,7 @@ func initConfig() {
} else {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
exitOnErr(rootCmd, err)
// Search config in `$HOME/.config/neofs-cli/` with name "config.yaml"
viper.AddConfigPath(filepath.Join(home, ".config", "neofs-cli"))