• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / modo / 12729458095

12 Jan 2025 01:54AM CUT coverage: 12.644%. Remained the same
12729458095

push

github

web-flow
Renames package doc to document (#17)

1 of 10 new or added lines in 4 files covered. (10.0%)

33 of 261 relevant lines covered (12.64%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/modo/root.go
1
package main
2

3
import (
4
        "fmt"
5
        "io"
6
        "log"
7
        "os"
8

9
        "github.com/mlange-42/modo"
10
        "github.com/mlange-42/modo/document"
11
        "github.com/mlange-42/modo/format"
12
        "github.com/spf13/cobra"
13
)
14

15
type renderFormats struct {
16
        mdBook bool
17
}
18

19
func rootCommand() *cobra.Command {
×
20
        var file string
×
21
        var formats renderFormats
×
22

×
23
        root := &cobra.Command{
×
24
                Use:   "modo <OUT>",
×
25
                Short: "Mojo documentation generator",
×
26
                Long:  ``,
×
27
                Args:  cobra.ExactArgs(1),
×
28
                RunE: func(cmd *cobra.Command, args []string) error {
×
29
                        outDir := args[0]
×
30

×
31
                        if outDir == "" {
×
32
                                return fmt.Errorf("no output path given")
×
33
                        }
×
34

35
                        data, err := read(file)
×
36
                        if err != nil {
×
37
                                return err
×
38
                        }
×
39

NEW
40
                        docs, err := document.FromJson(data)
×
41
                        if err != nil {
×
42
                                log.Fatal(err)
×
43
                        }
×
44

45
                        rFormat := getFormat(&formats)
×
46

×
47
                        err = modo.RenderPackage(&docs.Decl, outDir, rFormat, true)
×
48
                        if err != nil {
×
49
                                log.Fatal(err)
×
50
                        }
×
51

52
                        return nil
×
53
                },
54
        }
55

56
        root.Flags().StringVarP(&file, "input", "i", "", "File to read. Reads from STDIN if not specified.")
×
57
        root.Flags().BoolVar(&formats.mdBook, "mdbook", false, "Write in mdBook format.")
×
58

×
59
        root.MarkFlagsMutuallyExclusive("mdbook")
×
60

×
61
        return root
×
62
}
63

64
func read(file string) ([]byte, error) {
×
65
        if file == "" {
×
66
                return io.ReadAll(os.Stdin)
×
67
        } else {
×
68
                return os.ReadFile(file)
×
69
        }
×
70
}
71

72
func getFormat(f *renderFormats) format.Format {
×
73
        if f.mdBook {
×
74
                return format.MdBook
×
75
        }
×
76
        return format.Plain
×
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc