aptly graph specific output filename

https://github.com/smira/aptly/issues/241

	modify:     cmd/graph.go

Signed-off-by: Zhang, Guodong <gdzhang@linx-info.com>
This commit is contained in:
Zhang, Guodong
2015-04-24 11:11:12 +08:00
parent 1c8f1517f8
commit f3bcaa6cfb
+7
View File
@@ -35,8 +35,13 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
os.Remove(tempfile.Name())
format := context.Flags().Lookup("format").Value.String()
output := context.Flags().Lookup("output").Value.String()
tempfilename := tempfile.Name() + "." + format
if output != "" {
fmt.Printf("set file name option as %s . will output as %s.%s .\n", output, output, format)
tempfilename = output + "." + format
}
command := exec.Command("dot", "-T"+format, "-o"+tempfilename)
command.Stderr = os.Stderr
@@ -66,6 +71,7 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
return err
}
fmt.Printf("Rendered to %s file: %s, trying to open it...\n", format, tempfilename)
_ = exec.Command("open", tempfilename).Run()
@@ -90,6 +96,7 @@ Example:
}
cmd.Flag.String("format", "png", "render graph to specified format (png, svg, pdf, etc.)")
cmd.Flag.String("output", "", "specically output filename , default is output /tmp/aptlyxxxx.png")
return cmd
}