2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-06-27 09:02:49 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-03-12 13:58:40 +00:00
|
|
|
package process // import "storj.io/storj/pkg/process"
|
2018-06-27 09:02:49 +01:00
|
|
|
|
|
|
|
import (
|
2018-10-16 19:48:17 +01:00
|
|
|
"fmt"
|
2018-06-27 09:02:49 +01:00
|
|
|
"log"
|
|
|
|
"os"
|
2018-10-16 19:48:17 +01:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2019-04-03 20:13:39 +01:00
|
|
|
|
|
|
|
// We use a blank import here to get the side effects from the init function in version
|
|
|
|
_ "storj.io/storj/internal/version"
|
2018-06-27 09:02:49 +01:00
|
|
|
)
|
|
|
|
|
2018-10-16 19:48:17 +01:00
|
|
|
func init() {
|
|
|
|
cobra.MousetrapHelpText = "This is a command line tool.\n\n" +
|
|
|
|
"This needs to be run from a Command Prompt.\n"
|
|
|
|
|
|
|
|
// Figure out the executable name.
|
|
|
|
exe, err := os.Executable()
|
|
|
|
if err == nil {
|
|
|
|
cobra.MousetrapHelpText += fmt.Sprintf(
|
|
|
|
"Try running \"%s help\" for more information\n", exe)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-19 01:09:38 +01:00
|
|
|
// check if file exists, handle error correctly if it doesn't
|
2018-07-17 15:12:35 +01:00
|
|
|
func fileExists(path string) bool {
|
|
|
|
_, err := os.Stat(path)
|
|
|
|
if err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
log.Fatalf("failed to check for file existence: %v", err)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|