Skip to content

Commit

Permalink
Adds mllint render to pretty-print Markdown reports to terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
bvobart committed Aug 12, 2021
1 parent 400f497 commit cfcafde
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion categories/categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ var Deployment = api.Category{
Slug: "deployment",
Description: `This category evaluates your project's ability to be deployed in the real world.
It is not yet implemented, but may contain rules about Dockerfiles and configurability, among others.`,
It is not yet implemented, but may contain rules about Dockerfiles and configurability, among others.
Recommendations:
- [SeldonCore](https://github.com/SeldonIO/seldon-core) - An open source platform to deploy your machine learning models on Kubernetes at massive scale.
Seldon handles scaling to thousands of production machine learning models and provides advanced machine learning capabilities out of the box including
Advanced Metrics, Request Logging, Explainers, Outlier Detectors, A/B Tests, Canaries and more.`,
}

var Custom = api.Category{
Expand Down
43 changes: 43 additions & 0 deletions commands/render.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package commands

import (
"fmt"
"io/ioutil"
"path"

"github.com/bvobart/mllint/utils"
"github.com/bvobart/mllint/utils/markdown"
"github.com/spf13/cobra"
)

func NewRenderCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "render FILE",
Short: "Render an " + formatInlineCode("mllint") + " report to your terminal.",
Long: fmt.Sprintf(`Renders an %s report to your terminal in a pretty way.`, formatInlineCode("mllint")),
RunE: render,
Args: cobra.ExactArgs(1),
SilenceErrors: true,
SilenceUsage: true,
}
return cmd
}

func render(cmd *cobra.Command, args []string) error {
filename := args[0]
if !utils.FileExists(filename) {
return fmt.Errorf("cannot find file: %s", filename)
}

if path.Ext(filename) != ".md" {
return fmt.Errorf("mllint can only render Markdown files, but the provided filename does not end with '.md': %s", filename)
}

contents, err := ioutil.ReadFile(filename)
if err != nil {
return fmt.Errorf("cannot read from the given file: %w", err)
}

fmt.Println(markdown.Render(string(contents)))
return nil
}
1 change: 1 addition & 0 deletions commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func NewRootCommand() *cobra.Command {
cmd.AddCommand(NewRunCommand())
cmd.AddCommand(NewListCommand())
cmd.AddCommand(NewConfigCommand())
cmd.AddCommand(NewRenderCommand())
cmd.AddCommand(NewVersionCommand())
cmd.AddCommand(NewDescribeCommand())
return cmd
Expand Down

0 comments on commit cfcafde

Please sign in to comment.