Skip to content

Commit 2324297

Browse files
committed
feat: replacing input type boolean flags with string
1 parent a596116 commit 2324297

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ Binaries are being provided for both `linux` and `darwin`, in `amd64` arch.
2525
```bash
2626
$ curl -L "https://dl.bintray.com/mspier/binaries/darwin/amd64/burn" -o burn
2727
$ chmod +x burn
28-
$ ./burn <perf_output_file>
28+
$ ./burn <input_file>
2929
```
3030

3131
#### linux/amd64
3232

3333
```bash
3434
$ curl -L "https://dl.bintray.com/mspier/binaries/linux/amd64/burn" -o burn
3535
$ chmod +x burn
36-
$ ./burn <perf_output_file>
36+
$ ./burn <input_file>
3737
```
3838

3939
## Options
@@ -49,9 +49,10 @@ Examples:
4949
burn convert --html examples/out.perf
5050
burn convert --output=flame.json examples/out.perf
5151
burn convert --html --output=flame.html examples/out.perf
52+
perf script | burn convert --html
5253
5354
Usage:
54-
burn convert [flags] <input>
55+
burn convert [flags] (<input>)
5556
5657
Flags:
5758
-f, --folded input is a folded stack

cmd/convert.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
)
2626

2727
var pretty bool
28-
var folded bool
2928
var html bool
3029
var output string
30+
var input string
3131

3232
// convertCmd represents the convert command
3333
var convertCmd = &cobra.Command{
@@ -38,7 +38,7 @@ Convert performance profiles to a hierarchical data structure.
3838
3939
Examples:
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

Comments
 (0)