@@ -25,9 +25,9 @@ import (
2525)
2626
2727var pretty bool
28- var folded bool
2928var html bool
3029var output string
30+ var input string
3131
3232// convertCmd represents the convert command
3333var convertCmd = & cobra.Command {
@@ -38,7 +38,7 @@ Convert performance profiles to a hierarchical data structure.
3838
3939Examples:
4040 burn convert examples/out.perf
41- burn convert --folded examples/out.perf-folded
41+ burn convert --type= folded examples/out.perf-folded
4242 burn convert --html examples/out.perf
4343 burn convert --output=flame.json examples/out.perf
4444 burn convert --html --output=flame.html examples/out.perf
@@ -73,10 +73,12 @@ Examples:
7373 rootNode := types.Node {Name : "root" , Value : 0 , Children : make (map [string ]* types.Node )}
7474 profile := types.Profile {RootNode : rootNode , Stack : []string {}}
7575
76- if folded {
76+ if input == " folded" {
7777 profile = convert .ParseFolded (file )
78- } else {
78+ } else if input == "perf" {
7979 profile = convert .ParsePerf (file )
80+ } else {
81+ panic ("input type not supported: " + input )
8082 }
8183
8284 b := []byte {}
@@ -129,10 +131,10 @@ func init() {
129131 // Cobra supports Persistent Flags which will work for this command
130132 // and all subcommands, e.g.:
131133 // convertCmd.PersistentFlags().String("foo", "", "A help for foo")
132- convertCmd .PersistentFlags ().BoolVarP (& folded , "folded" , "f" , false , "input is a folded stack" )
133134 convertCmd .PersistentFlags ().BoolVarP (& pretty , "pretty" , "p" , false , "json output is pretty printed" )
134135 convertCmd .PersistentFlags ().BoolVarP (& html , "html" , "m" , false , "output is a html flame graph" )
135136 convertCmd .PersistentFlags ().StringVar (& output , "output" , "" , "output file" )
137+ convertCmd .PersistentFlags ().StringVar (& input , "type" , "perf" , "input type" )
136138
137139 // Cobra supports local flags which will only run when this command
138140 // is called directly, e.g.:
0 commit comments