lib/git/story/utils.rb in git-story-workflow-0.0.1 vs lib/git/story/utils.rb in git-story-workflow-0.0.2
- old
+ new
@@ -2,14 +2,22 @@
module Git::Story::Utils
include FileUtils::Verbose
def sh(*a, error: true)
+ @debug and STDERR.puts("Executing #{a * ' '}")
system(*a)
if error && !$?.success?
STDERR.puts ("Failed with rc #{$?.exitstatus}: " + a.join(' ')).red
exit $?.exitstatus
end
+ end
+
+ def capture(command)
+ @debug and STDERR.puts("Executing #{command.inspect}")
+ result = `#{command}`
+ @debug and STDERR.puts("Result\n#{result}")
+ result
end
def ask(prompt: '? ', **options, &block)
response = options[:preset]
unless response