From f7ba37b5a6d3521c3f6a1a4889e56e1303b09211 Mon Sep 17 00:00:00 2001 From: fatkodima Date: Tue, 21 Feb 2023 15:16:03 +0200 Subject: [PATCH] Fix printing CLI banner --- bin/stackprof | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/stackprof b/bin/stackprof index 6981e357..e9b8afd5 100755 --- a/bin/stackprof +++ b/bin/stackprof @@ -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 @@ -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 }