cmd.NewRootCommand   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 16
nop 1
dl 0
loc 23
rs 9.6
c 0
b 0
f 0
1
package cmd
2
3
import (
4
	"github.com/sirupsen/logrus"
5
	"github.com/spf13/cobra"
6
)
7
8
func NewRootCommand(logger *logrus.Logger) *cobra.Command {
9
	var verbose bool
10
11
	cmd := &cobra.Command{
12
		Use:   "dirstalk",
13
		Short: "Stalk the given url trying to enumerate files and folders",
14
		Long:  `dirstalk is a tool that attempts to enumerate files and folders starting from a given URL`,
15
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
16
			if verbose {
17
				logger.SetLevel(logrus.DebugLevel)
18
			}
19
		},
20
	}
21
22
	cmd.PersistentFlags().BoolVarP(
23
		&verbose,
24
		flagRootVerbose,
25
		flagRootVerboseShort,
26
		false,
27
		"verbose mode",
28
	)
29
30
	return cmd
31
}
32