Skip to content

Commit d5973fa

Browse files
committed
Restore root command after merge breakage
1 parent d90a423 commit d5973fa

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

cmd/root.go

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
package cmd
22

3-
rootCmd.SetHelpTemplate(`FlutterGuard CLI - Analyze Flutter Android APKs for security insights
4-
5-
Usage:
6-
{{.UseLine}}
7-
8-
{{if .HasAvailableFlags}}Options:
9-
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
10-
{{end}}
11-
{{if .HasAvailableSubCommands}}Commands:
12-
{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
13-
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
14-
{{end}}
15-
Examples:
16-
# Analyze APK with structured output (recommended)
17-
{{.CommandPath}} --apk app.apk --outDir ./results --verbose
18-
19-
# Quick text report
20-
{{.CommandPath}} --apk app.apk --format text
21-
22-
# Offline analysis (default)
23-
{{.CommandPath}} --apk app.apk --outDir ./results
24-
25-
# Enable network checks for full validation
26-
{{.CommandPath}} --apk app.apk --outDir ./results --enable-network-and-dns-checks
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
8+
"github.com/spf13/cobra"
9+
)
10+
11+
const Version = "0.9.3"
12+
13+
// CLIConfig holds CLI options passed via flags
14+
type CLIConfig struct {
15+
OutputFormat string
16+
OutputDir string
17+
Verbose bool
18+
EnableNetworkAndDNS bool
19+
}
2720

28-
More info: https://github.com/flutterguard/flutterguard-cli
29-
`)
21+
var (
22+
apkPath string
23+
cfg CLIConfig
24+
showVersion bool
25+
)
26+
27+
var rootCmd = &cobra.Command{
28+
Use: "flutterguard",
29+
Short: "FlutterGuard CLI - Analyze Flutter Android APKs for security insights",
30+
Long: "FlutterGuard CLI is a tool to analyze Flutter Android APKs for security issues, misconfigurations, and sensitive data exposure.",
31+
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
32+
if len(os.Args) == 1 {
33+
_ = cmd.Help()
34+
os.Exit(0)
3035
}
3136
return nil
3237
},
@@ -75,26 +80,19 @@ More info: https://github.com/flutterguard/flutterguard-cli
7580
}
7681

7782
func init() {
83+
rootCmd.SetHelpTemplate(`FlutterGuard CLI - Analyze Flutter Android APKs for security insights
7884
79-
rootCmd.SetHelpTemplate(` ___ _ _ _ ___ _
80-
/ __\ |_ _| |_| |_ ___ _ __ / _ \/\ /\ __ _ _ __ __| |
81-
/ _\ | | | | | __| __/ _ \ '__/ /_\/ / \ \/ _` + "`" + ` | '__/ _` + "`" + ` |
82-
/ / | | |_| | |_| || __/ | / /_\\\ \_/ / (_| | | | (_| |
83-
\/ |_|\__,_|\__|\__\___|_| \____/ \___/ \__,_|_| \__,_|
84-
85-
86-
USAGE:
85+
Usage:
8786
{{.UseLine}}
8887
89-
90-
91-
{{end}}{{if .HasAvailableFlags}}OPTIONS:
88+
{{if .HasAvailableFlags}}Options:
9289
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
93-
94-
{{end}}{{if .HasAvailableSubCommands}}COMMANDS:
90+
{{end}}
91+
{{if .HasAvailableSubCommands}}Commands:
9592
{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
9693
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}
97-
{{end}}EXAMPLES:
94+
{{end}}
95+
Examples:
9896
# Analyze APK with structured output (recommended)
9997
{{.CommandPath}} --apk app.apk --outDir ./results --verbose
10098
@@ -107,13 +105,12 @@ USAGE:
107105
# Enable network checks for full validation
108106
{{.CommandPath}} --apk app.apk --outDir ./results --enable-network-and-dns-checks
109107
110-
For more information, visit: https://github.com/flutterguard/flutterguard-cli
108+
More info: https://github.com/flutterguard/flutterguard-cli
111109
`)
112110
}
113111

114112
// Execute runs the root Cobra command
115113
func Execute() {
116-
117114
rootCmd.Flags().StringVar(&apkPath, "apk", "", "Flutter app APK file to analyze")
118115
rootCmd.Flags().StringVar(&cfg.OutputFormat, "format", "json", "Output format: json or text (used when --outDir not set)")
119116
rootCmd.Flags().StringVar(&cfg.OutputDir, "outDir", "", "Output directory for structured results (creates folder with app package name), if not set, outputs to stdout")

0 commit comments

Comments
 (0)