Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: graphviz cmd based on gno-roadmap implem #659

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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