lib/synvert/cli.rb in synvert-0.18.4 vs lib/synvert/cli.rb in synvert-0.19.0
- old
+ new
@@ -32,11 +32,10 @@
open_rewriter
when 'query'
load_rewriters
query_available_rewriters
when 'show'
- load_rewriters
show_rewriter
when 'sync'
sync_snippets
when 'generate'
generate_snippet
@@ -73,41 +72,44 @@
@options[:custom_snippet_paths] = snippet_paths.split(',').map(&:strip)
end
opts.on '-l', '--list', 'list all available snippets' do
@options[:command] = 'list'
end
- opts.on '-o', '--open SNIPPET_NAME', 'Open a snippet' do |snippet_name|
- @options[:command] = 'open'
- @options[:snippet_name] = snippet_name
- end
opts.on '-q', '--query QUERY', 'query specified snippets' do |query|
@options[:command] = 'query'
@options[:query] = query
end
- opts.on '--skip FILE_PATTERNS',
- 'skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb' do |file_patterns|
- @options[:skip_file_patterns] = file_patterns.split(',')
- end
opts.on '-s',
'--show SNIPPET_NAME',
'show specified snippet description, SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax' do |snippet_name|
@options[:command] = 'show'
@options[:snippet_name] = snippet_name
end
+ opts.on '-o', '--open SNIPPET_NAME', 'Open a snippet' do |snippet_name|
+ @options[:command] = 'open'
+ @options[:snippet_name] = snippet_name
+ end
+ opts.on '-g', '--generate NEW_SNIPPET_NAME', 'generate a new snippet' do |name|
+ @options[:command] = 'generate'
+ @options[:snippet_name] = name
+ end
opts.on '--sync', 'sync snippets' do
@options[:command] = 'sync'
end
opts.on '--execute', 'execute snippet' do
@options[:command] = 'execute'
end
opts.on '-r', '--run SNIPPET_NAME', 'run specified snippet, e.g. ruby/new_hash_syntax' do |snippet_name|
@options[:snippet_name] = snippet_name
end
- opts.on '-g', '--generate NEW_SNIPPET_NAME', 'generate a new snippet' do |name|
- @options[:command] = 'generate'
- @options[:snippet_name] = name
+ opts.on '--show-run-process', 'show processing files when running a snippet' do
+ Core::Configuration.show_run_process = true
end
+ opts.on '--skip FILE_PATTERNS',
+ 'skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb' do |file_patterns|
+ @options[:skip_file_patterns] = file_patterns.split(',')
+ end
opts.on '-f', '--format FORMAT', 'output format' do |format|
@options[:format] = format
end
opts.on '-v', '--version', 'show this version' do
puts "#{VERSION} (with synvert-core #{Core::VERSION} and parser #{Parser::VERSION})"
@@ -183,10 +185,10 @@
def open_rewriter
editor = [ENV['SYNVERT_EDITOR'], ENV['EDITOR']].find { |e| !e.nil? && !e.empty? }
return puts 'To open a synvert snippet, set $EDITOR or $SYNVERT_EDITOR' unless editor
path = File.expand_path(File.join(default_snippets_home, "lib/#{@options[:snippet_name]}.rb"))
- if File.exist? path
+ if File.exist?(path)
system editor, path
else
puts "Can't run #{editor} #{path}"
end
end