Class: RuboCop::Schema::CLI
- Inherits:
-
Object
- Object
- RuboCop::Schema::CLI
- Defined in:
- lib/rubocop/schema/cli.rb
Instance Method Summary collapse
-
#initialize(working_dir: Dir.pwd, env: ENV, args: ARGV, home: Dir.home, out_file: nil, log_file: $stderr) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(working_dir: Dir.pwd, env: ENV, args: ARGV, home: Dir.home, out_file: nil, log_file: $stderr) ⇒ CLI
Returns a new instance of CLI.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubocop/schema/cli.rb', line 19 def initialize(working_dir: Dir.pwd, env: ENV, args: ARGV, home: Dir.home, out_file: nil, log_file: $stderr) @working_dir = Pathname(working_dir) @home_dir = Pathname(home) @env = env @args = args @out_file = out_file @log_file = log_file raise ArgumentError, 'Cannot accept an out_file and an argument' if @out_file && args.first end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/schema/cli.rb', line 30 def run read_flag while @args.first&.start_with?('--') assign_outfile print "Generating #{@out_path} … " if @out_path schema = report_duration(lowercase: @out_path) { Generator.new(spec.specs, document_loader).schema } @out_file.puts JSON.pretty_generate schema end |