-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommand.go
More file actions
44 lines (35 loc) · 965 Bytes
/
command.go
File metadata and controls
44 lines (35 loc) · 965 Bytes
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
40
41
42
43
44
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var (
packageName string
token string
)
var rootCmd = &cobra.Command{
Use: "qp_flutter",
Short: "QP Flutter CLI tool",
}
var createCmd = &cobra.Command{
Use: "create [app_name]",
Short: "Create a new Flutter app from template",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
appName := args[0]
// Get GitHub token from environment
githubToken := os.Getenv("GITHUB_TOKEN")
if githubToken == "" {
return fmt.Errorf("GITHUB_TOKEN environment variable is required")
}
// Create the app
return createFlutterApp(appName, githubToken, packageName)
},
}
func init() {
createCmd.Flags().StringVarP(&packageName, "package", "p", "", "Package name (e.g. com.company.app)")
createCmd.Flags().StringVarP(&token, "token", "t", "", "GitHub personal access token")
createCmd.MarkFlagRequired("package")
rootCmd.AddCommand(createCmd)
}