-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.go
More file actions
100 lines (87 loc) · 2.68 KB
/
Copy pathroot.go
File metadata and controls
100 lines (87 loc) · 2.68 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package cli
import (
"github.com/dvflw/mantle/internal/config"
"github.com/spf13/cobra"
)
// NewRootCommand creates the root mantle CLI command.
func NewRootCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "mantle",
Short: "Headless AI workflow automation platform",
Long: `Mantle is a headless AI workflow automation platform.
BYOK, IaC-first, enterprise-grade, source-available.
validate → plan → apply → run
Full documentation: https://mantle.dvflw.co/docs`,
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
cfg, err := config.Load(cmd)
if err != nil {
return err
}
cmd.SetContext(config.WithContext(cmd.Context(), cfg))
return nil
},
}
cmd.PersistentFlags().String("config", "", "config file path (default: mantle.yaml)")
cmd.PersistentFlags().String("database-url", "", "database connection URL")
cmd.PersistentFlags().String("api-address", "", "API listen address")
cmd.PersistentFlags().String("log-level", "", "log level (debug, info, warn, error)")
cmd.PersistentFlags().String("api-key", "", "API key for authentication (overrides cached credentials)")
cmd.PersistentFlags().StringP("output", "o", "text", "Output format: text or json")
cmd.PersistentFlags().Int("max-workflow-depth", 0, "Maximum workflow nesting depth (default: 10)")
// Command groups for organized help output.
cmd.AddGroup(
&cobra.Group{ID: "workflow", Title: "Workflow Lifecycle:"},
&cobra.Group{ID: "server", Title: "Server & Triggers:"},
&cobra.Group{ID: "auth", Title: "Authentication & Secrets:"},
&cobra.Group{ID: "admin", Title: "Administration:"},
&cobra.Group{ID: "info", Title: "Info:"},
)
// Workflow lifecycle commands.
addToGroup(cmd, "workflow",
newValidateCommand(),
newPlanCommand(),
newApplyCommand(),
newRunCommand(),
newRetryCommand(),
newRollbackCommand(),
newCancelCommand(),
newLogsCommand(),
newStatusCommand(),
)
// Server & triggers.
addToGroup(cmd, "server",
newServeCommand(),
)
// Authentication & secrets.
addToGroup(cmd, "auth",
newSecretsCommand(),
newLoginCommand(),
newLogoutCommand(),
)
// Administration.
addToGroup(cmd, "admin",
newInitCommand(),
newMigrateCommand(),
newTeamsCommand(),
newUsersCommand(),
newRolesCommand(),
newAuditCommand(),
newPluginsCommand(),
newLibraryCommand(),
newCleanupCommand(),
newBudgetCommand(),
)
// Info.
addToGroup(cmd, "info",
newVersionCommand(),
)
return cmd
}
// addToGroup sets GroupID on each command and adds it to the parent.
func addToGroup(parent *cobra.Command, groupID string, cmds ...*cobra.Command) {
for _, c := range cmds {
c.GroupID = groupID
parent.AddCommand(c)
}
}