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"
|
|
|
|
|
2020-03-23 19:18:20 +00:00
|
|
|
"storj.io/private/process"
|
2018-09-07 16:01:04 +01:00
|
|
|
"storj.io/storj/cmd/uplink/cmd"
|
2020-04-01 08:12:26 +01:00
|
|
|
_ "storj.io/storj/private/version" // This attaches version information during release builds.
|
2018-07-30 08:38:31 +01:00
|
|
|
)
|
|
|
|
|
2018-07-26 15:21:35 +01:00
|
|
|
func main() {
|
2020-01-28 17:35:45 +00:00
|
|
|
process.ExecWithCustomConfig(cmd.RootCmd, true, func(cmd *cobra.Command, vip *viper.Viper) error {
|
2020-01-09 13:38:19 +00:00
|
|
|
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
|
|
|
}
|