Skip to content

Commit

Permalink
fix: pass generated filename as arg
Browse files Browse the repository at this point in the history
Signed-off-by: ismael FALL <ismael.fall@epitech.eu>
  • Loading branch information
Doozers committed Apr 13, 2023
1 parent 2b2d9b6 commit 13ca545
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/depviz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var (
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 @@ -376,6 +377,7 @@ func execGenGraphviz(ctx context.Context, args []string) error {
GenOpts: genOpts,
Label: *graphvizLabel,
Type: *graphvizType,
File: *graphvizFile,
}

return dvcore.GenGraphviz(store, args, opts)
Expand Down
7 changes: 6 additions & 1 deletion pkg/dvcore/graphviz.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dvcore

import (
"fmt"
"os"
"strings"

"github.com/cayleygraph/cayley"
Expand All @@ -20,6 +21,7 @@ type GraphvizOpts struct {
// graphviz
Label string
Type string
File string
}

func GenGraphviz(h *cayley.Handle, args []string, opts GraphvizOpts) error {
Expand Down Expand Up @@ -106,7 +108,10 @@ func GenGraphviz(h *cayley.Handle, args []string, opts GraphvizOpts) error {
_ = edge
}
}
return g.RenderFilename(graph, graphviz.Format(opts.Type), "graph."+opts.Type)
if opts.File == "" {
return g.Render(graph, graphviz.Format(opts.Type), os.Stdout)
}
return g.RenderFilename(graph, graphviz.Format(opts.Type), opts.File)
}

func fmtIRI(s quad.IRI) string {
Expand Down

0 comments on commit 13ca545

Please sign in to comment.