-
Notifications
You must be signed in to change notification settings - Fork 402
/
exec.go
39 lines (32 loc) · 903 Bytes
/
exec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package process // import "storj.io/storj/pkg/process"
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
// We use a blank import here to get the side effects from the init function in version
_ "storj.io/storj/internal/version"
)
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)
}
}
// check if file exists, handle error correctly if it doesn't
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
}