Class: Synvert::CLI
- Inherits:
-
Object
- Object
- Synvert::CLI
- Defined in:
- lib/synvert/cli.rb
Overview
Synvert command line interface.
Class Method Summary collapse
-
.run(args = ARGV) ⇒ Boolean
Initialize the cli and run.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
Initialize a CLI.
-
#run(args) ⇒ Boolean
Run the CLI.
Constructor Details
#initialize ⇒ CLI
Initialize a CLI.
17 18 19 20 |
# File 'lib/synvert/cli.rb', line 17 def initialize @options = {command: 'run', snippet_paths: [], snippet_names: []} Configuration.instance.set :skip_files, [] end |
Class Method Details
.run(args = ARGV) ⇒ Boolean
Initialize the cli and run.
12 13 14 |
# File 'lib/synvert/cli.rb', line 12 def self.run(args = ARGV) new.run(args) end |
Instance Method Details
#run(args) ⇒ Boolean
Run the CLI.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/synvert/cli.rb', line 25 def run(args) run_option_parser(args) load_rewriters case @options[:command] when 'list' then list_available_rewriters when 'query' then query_available_rewriters when 'show' then show_rewriter else @options[:snippet_names].each do |snippet_name| puts "===== #{snippet_name} started =====" rewriter = Rewriter.call snippet_name puts rewriter.todo if rewriter.todo puts "===== #{snippet_name} done =====" end end true rescue SystemExit true rescue Parser::SyntaxError => e puts "Syntax error: #{e.}" puts "file #{e.diagnostic.location.source_buffer.name}" puts "line #{e.diagnostic.location.line}" false rescue Exception => e print "Error: " p e false end |