Skip to content

Commit

Permalink
Go2md v0.3 (#3)
Browse files Browse the repository at this point in the history
* warn about missing doc.go

* warn about types that are not exported

* bugfixes (for example [])

* `--output` argument to direct output into file

* line-up tags in struct fields
  • Loading branch information
jylitalo authored Feb 20, 2023
1 parent 4c50f98 commit 586f66d
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 238 deletions.
6 changes: 4 additions & 2 deletions cmd/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# github.com/jylitalo/go2md/cmd

## Overview
Package cmd provides command line arguments and flags parsing with spf13/cobra and
calls backend functionality from pkg package.

Imports: 4
Imports: 6

## Index
- [func NewCommand(out io.Writer, version string) *cobra.Command](#func-newcommand)
Expand Down Expand Up @@ -33,5 +35,5 @@ Default is to generate markdown from current directory.

--

Generated by [github.com/jylitalo/go2md](https://github.com/jylitalo/go2cmd/) v0.2
Generated by [github.com/jylitalo/go2md](https://github.com/jylitalo/go2md/) v0.3

11 changes: 11 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package cmd
import (
"fmt"
"io"
"os"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/jylitalo/go2md/pkg"
Expand All @@ -19,9 +21,18 @@ func NewCommand(out io.Writer, version string) *cobra.Command {
out.Write([]byte(fmt.Sprintf("go2md %s\n", version)))
return nil
}
if flag, _ := cmd.Flags().GetString("output"); flag != "" {
fout, err := os.Create(flag)
if err != nil {
log.WithFields(log.Fields{"err": err, "filename": flag}).Fatal("failed to create file")
}
defer fout.Close()
out = fout
}
return pkg.Run(out, version)
},
}
cmd.Flags().BoolP("version", "v", false, "print go2md version")
cmd.Flags().StringP("output", "o", "", "write output to file")
return cmd
}
3 changes: 3 additions & 0 deletions cmd/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package cmd provides command line arguments and flags parsing with spf13/cobra and
// calls backend functionality from pkg package.
package cmd
5 changes: 3 additions & 2 deletions pkg/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# github.com/jylitalo/go2md/pkg

## Overview
Package pkg provides the backend functionality for golang to markdown transformation.

Imports: 15
Imports: 16

## Index
- [Variables](variables)
Expand Down Expand Up @@ -37,5 +38,5 @@ Run reads all "*.go" files (excluding "*_test.go") and writes markdown document

--

Generated by [github.com/jylitalo/go2md](https://github.com/jylitalo/go2cmd/) v0.2
Generated by [github.com/jylitalo/go2md](https://github.com/jylitalo/go2md/) v0.3

2 changes: 2 additions & 0 deletions pkg/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package pkg provides the backend functionality for golang to markdown transformation.
package pkg
Loading

0 comments on commit 586f66d

Please sign in to comment.