MCPcopy
hub / github.com/danielmiessler/Fabric / Cli

Function Cli

internal/cli/cli.go:17–115  ·  view source on GitHub ↗

Cli Controls the cli. It takes in the flags and runs the appropriate functions

(version string)

Source from the content-addressed store, hash-verified

15
16// Cli Controls the cli. It takes in the flags and runs the appropriate functions
17func Cli(version string) (err error) {
18 var currentFlags *Flags
19 if currentFlags, err = Init(); err != nil {
20 return
21 }
22
23 // initialize internationalization using requested language
24 if _, err = i18n.Init(currentFlags.Language); err != nil {
25 return
26 }
27
28 if currentFlags.Setup {
29 if err = ensureEnvFile(); err != nil {
30 return
31 }
32 }
33
34 if currentFlags.Version {
35 fmt.Println(version)
36 return
37 }
38
39 // Initialize database and registry
40 var registry, err2 = initializeFabric()
41 if err2 != nil {
42 if !currentFlags.Setup {
43 debuglog.Log("%s\n", err2.Error())
44 currentFlags.Setup = true
45 }
46 // Return early if registry is nil to prevent panics in subsequent handlers
47 if registry == nil {
48 return err2
49 }
50 }
51
52 // Configure OpenAI Responses API setting based on CLI flag
53 if registry != nil {
54 configureOpenAIResponsesAPI(registry, currentFlags.DisableResponsesAPI)
55 }
56
57 // Handle setup and server commands
58 var handled bool
59 if handled, err = handleSetupAndServerCommands(currentFlags, registry, version); err != nil || handled {
60 return
61 }
62
63 // Handle configuration commands
64 if handled, err = handleConfigurationCommands(currentFlags, registry); err != nil || handled {
65 return
66 }
67
68 // Handle listing commands
69 if handled, err = handleListingCommands(currentFlags, registry.Db, registry); err != nil || handled {
70 return
71 }
72
73 // Handle management commands
74 if handled, err = handleManagementCommands(currentFlags, registry.Db); err != nil || handled {

Callers 2

mainFunction · 0.92
TestCliFunction · 0.85

Calls 15

IsChatRequestMethod · 0.95
InitFunction · 0.92
HtmlReadabilityFunction · 0.92
TFunction · 0.92
ensureEnvFileFunction · 0.85
initializeFabricFunction · 0.85
handleListingCommandsFunction · 0.85
handleManagementCommandsFunction · 0.85
handleExtensionCommandsFunction · 0.85

Tested by 1

TestCliFunction · 0.68