lib/synvert/cli.rb in synvert-0.12.0 vs lib/synvert/cli.rb in synvert-0.12.1
- old
+ new
@@ -112,13 +112,11 @@
opts.on '-r',
'--run SNIPPET_NAMES',
'run specified snippets, each SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax,ruby/new_lambda_syntax' do |snippet_names|
@options[:snippet_names] = snippet_names.split(',').map(&:strip)
end
- opts.on '-g',
- '--generate NEW_SNIPPET_NAME',
- 'generate a new snippet' do |name|
+ opts.on '-g', '--generate NEW_SNIPPET_NAME', 'generate a new snippet' do |name|
@options[:command] = 'generate'
@options[:snippet_name] = name
end
opts.on '-v', '--version', 'show this version' do
puts "#{VERSION} (with synvert-core #{Core::VERSION} and parser #{Parser::VERSION})"
@@ -222,21 +220,12 @@
puts
end
# Show and print one rewriter.
def show_rewriter
- group, name = @options[:snippet_name].split('/')
- rewriter = Core::Rewriter.fetch(group, name)
- if rewriter
- rewriter.process_with_sandbox
- puts rewriter.description
- rewriter.sub_snippets.each do |sub_rewriter|
- puts
- puts '=' * 80
- puts "snippet: #{sub_rewriter.name}"
- puts '=' * 80
- puts sub_rewriter.description
- end
+ path = File.expand_path(File.join(default_snippets_path, "lib/#{@options[:snippet_name]}.rb"))
+ if File.exist?(path)
+ puts File.read(path)
else
puts "snippet #{@options[:snippet_name]} not found"
end
end