2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-07-26 15:21:35 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-01-09 13:38:19 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
2018-09-07 16:01:04 +01:00
|
|
|
"storj.io/storj/cmd/uplink/cmd"
|
2018-07-26 15:21:35 +01:00
|
|
|
"storj.io/storj/pkg/process"
|
2018-07-30 08:38:31 +01:00
|
|
|
)
|
|
|
|
|
2018-07-26 15:21:35 +01:00
|
|
|
func main() {
|
2020-01-09 13:38:19 +00:00
|
|
|
process.ExecWithCustomConfig(cmd.RootCmd, func(cmd *cobra.Command, vip *viper.Viper) error {
|
|
|
|
accessFlag := cmd.Flags().Lookup("access")
|
2020-01-10 15:51:28 +00:00
|
|
|
// try to load configuration because we may still need 'accesses' (for named access)
|
|
|
|
// field but error only if 'access' flag is not set
|
|
|
|
err := process.LoadConfig(cmd, vip)
|
|
|
|
if err != nil && (accessFlag == nil || accessFlag.Value.String() == "") {
|
|
|
|
return err
|
2020-01-09 13:38:19 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2018-07-26 15:21:35 +01:00
|
|
|
}
|