2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/brief/cli/01_extensions.rb', line 2
def action(*a, &block)
Brief.default_cli_options(self)
when_called do |args, options|
options.default(root: Brief.pwd, config_filename: 'brief.rb', format: :printed)
root = Pathname(options.root)
if root.join(options.config_filename).exist?
Brief.case = Brief::Briefcase.new(root: root)
end
result = block.call(args, options)
case
when options.output && options.format.to_sym == :json
Pathname(options.output).open("w+") do |fh|
fh.write(result.to_json)
end
when options.format.to_sym == :json
puts result.to_json
when options.format.to_sym == :printed
puts result
end
end
end
|