MCPcopy Create free account
hub / github.com/algolia/cli / run

Function run

cmd/docs/main.go:24–62  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

22}
23
24func run(args []string) error {
25 flags := pflag.NewFlagSet("", pflag.ContinueOnError)
26 dir := flags.StringP(
27 "app_data-path",
28 "",
29 "",
30 "Path directory where you want generate documentation data files",
31 )
32 help := flags.BoolP("help", "h", false, "Help about any command")
33 if err := flags.Parse(args); err != nil {
34 return err
35 }
36
37 if *help {
38 fmt.Fprintf(os.Stderr, "Usage of %s:\n\n%s", filepath.Base(args[0]), flags.FlagUsages())
39 return nil
40 }
41
42 if *dir == "" {
43 return fmt.Errorf("error: --app_data-path not set")
44 }
45
46 ios, _, _, _ := iostreams.Test()
47 rootCmd := root.NewRootCmd(&cmdutil.Factory{
48 IOStreams: ios,
49 Config: &config.Config{},
50 })
51 rootCmd.InitDefaultHelpCmd()
52
53 if err := os.MkdirAll(*dir, 0o755); err != nil {
54 return err
55 }
56
57 if err := docs.GenMdxTree(rootCmd, *dir); err != nil {
58 return err
59 }
60
61 return nil
62}

Callers 1

mainFunction · 0.85

Calls 4

TestFunction · 0.92
NewRootCmdFunction · 0.92
GenMdxTreeFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected