Skip to content

Commit

Permalink
Fix printing CLI banner
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Feb 21, 2023
1 parent 86b9cc6 commit f7ba37b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions bin/stackprof
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
require 'optparse'
require 'stackprof'

banner = <<-END
Usage: stackprof run [--mode=MODE|--out=FILE|--interval=INTERVAL|--format=FORMAT] -- COMMAND
Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]
END

if ARGV.first == "run"
ARGV.shift
env = {}
parser = OptionParser.new(ARGV) do |o|
o.banner = "Usage: stackprof run [--mode=MODE|--out=FILE|--interval=INTERVAL|--format=FORMAT] -- COMMAND"
o.banner = "Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]"

parser = OptionParser.new(banner) do |o|
o.on('--mode [MODE]', String, 'Mode of sampling: cpu, wall, object, default to wall') do |mode|
env["STACKPROF_MODE"] = mode
end
Expand Down Expand Up @@ -37,10 +39,7 @@ if ARGV.first == "run"
else
options = {}

parser = OptionParser.new(ARGV) do |o|
o.banner = "Usage: stackprof run [--mode|--out|--interval] -- COMMAND"
o.banner = "Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]"

parser = OptionParser.new(banner) do |o|
o.on('--text', 'Text summary per method (default)'){ options[:format] = :text }
o.on('--json', 'JSON output (use with web viewers)'){ options[:format] = :json }
o.on('--files', 'List of files'){ |f| options[:format] = :files }
Expand Down

0 comments on commit f7ba37b

Please sign in to comment.