7
7
"github.com/spf13/cobra"
8
8
"github.com/spf13/viper"
9
9
10
- "github.com/mistsys/go-tenable/tenable"
11
10
"github.com/mistsys/go-tenable/outputs"
11
+ "github.com/mistsys/go-tenable/tenable"
12
12
)
13
13
14
14
var (
@@ -25,7 +25,11 @@ var rootCmd = &cobra.Command{
25
25
Use : "tenable COMMAND" ,
26
26
Short : "A CLI for the Tenable API" ,
27
27
PersistentPreRun : func (cmd * cobra.Command , args []string ) {
28
- client = tenable .NewClient (viper .GetString ("accesskey" ), viper .GetString ("secretkey" ))
28
+ viper .AutomaticEnv ()
29
+ viper .SetEnvPrefix ("TENABLE" )
30
+ accessKey := viper .GetString ("accesskey" )
31
+ secretKey := viper .GetString ("secretkey" )
32
+ client = tenable .NewClient (accessKey , secretKey )
29
33
// using viper means the cobra *Var flag options don't actually populate the global variables from config files
30
34
// if we have to manually set them anyway, we'll just manually set them
31
35
debug := viper .GetBool ("debug" )
@@ -34,17 +38,17 @@ var rootCmd = &cobra.Command{
34
38
client .QueryOpts = queryOpts
35
39
36
40
/*
37
- var outputFd *os.File
38
- var err error // ???
39
- if outputFilename == "-" {
40
- outputFd = os.Stdout
41
- } else {
42
- outputFd, err = outputs.NewFile(outputFilename)
43
- if err != nil {
44
- fmt.Println("Error creating output file:", err)
45
- os.Exit(1)
41
+ var outputFd *os.File
42
+ var err error // ???
43
+ if outputFilename == "-" {
44
+ outputFd = os.Stdout
45
+ } else {
46
+ outputFd, err = outputs.NewFile(outputFilename)
47
+ if err != nil {
48
+ fmt.Println("Error creating output file:", err)
49
+ os.Exit(1)
50
+ }
46
51
}
47
- }
48
52
*/
49
53
50
54
// TODO remove outputter entirely
0 commit comments