Skip to content

Commit

Permalink
feat: graphviz cmd based on gno-roadmap implem (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doozers authored Apr 13, 2023
1 parent 6deccbc commit 80f6ae5
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 60 deletions.
37 changes: 35 additions & 2 deletions cmd/depviz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ var (
fetchFlags = flag.NewFlagSet("fetch", flag.ExitOnError)
fetchGitHubToken = fetchFlags.String("github-token", "", "GitHub token")
fetchResync = fetchFlags.Bool("resync", false, "resync already synced content")

graphvizFlags = flag.NewFlagSet("graphviz", flag.ExitOnError)
graphvizLabel = graphvizFlags.String("label", "", "label to use for the graph")
graphvizType = graphvizFlags.String("type", "svg", "output type (svg, png, dot)")
graphvizFile = graphvizFlags.String("file", "", "output file (default: stdout)")
)

func main() {
Expand Down Expand Up @@ -130,7 +135,7 @@ func Main(args []string) error {
Name: "gen",
ShortHelp: "use the db to generate outputs, without requiring any fetch",
Subcommands: []*ffcli.Command{
{Name: "graphviz", Exec: execGenGraphviz, ShortHelp: "generate graphviz output"},
{Name: "graphviz", Exec: execGenGraphviz, ShortHelp: "generate graphviz output", FlagSet: graphvizFlags},
{Name: "json", Exec: execGenJSON, ShortHelp: "generate JSON output"},
{Name: "csv", Exec: execGenCSV, ShortHelp: "generate CSV output"},
},
Expand Down Expand Up @@ -347,7 +352,35 @@ func storeFromArgs() (*cayley.Handle, error) {
}

func execGenGraphviz(ctx context.Context, args []string) error {
return fmt.Errorf("not implemented yet")
if err := globalPreRun(); err != nil {
return err
}

store, err := storeFromArgs()
if err != nil {
return fmt.Errorf("init store: %w", err)
}

genOpts := &dvcore.GenOpts{
Logger: logger,
Schema: schemaConfig,
Vertical: *genVertical,
NoPert: *genNoPert,
NoGraph: *genNoGraph,
ShowClosed: *genShowClosed,
HideIsolated: *genHideIsolated,
HidePRs: *genHidePRs,
HideExternalDeps: *genHideExternalDeps,
}

opts := dvcore.GraphvizOpts{
GenOpts: genOpts,
Label: *graphvizLabel,
Type: *graphvizType,
File: *graphvizFile,
}

return dvcore.GenGraphviz(store, args, opts)
}

func execGenJSON(ctx context.Context, args []string) error {
Expand Down
9 changes: 6 additions & 3 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 27 additions & 6 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80f6ae5

Please sign in to comment.