Class: SyntaxTree::CLI::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/cli.rb

Overview

We allow a minimal configuration file to act as additional command line arguments to the CLI. Each line of the config file should be a new argument, as in:

--plugins=plugin/single_quote
--print-width=100

When invoking the CLI, we will read this config file and then parse it if it exists in the current working directory.

Constant Summary collapse

FILENAME =
".streerc"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigFile



459
460
461
# File 'lib/syntax_tree/cli.rb', line 459

def initialize
  @filepath = File.join(Dir.pwd, FILENAME)
end

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



457
458
459
# File 'lib/syntax_tree/cli.rb', line 457

def filepath
  @filepath
end

Instance Method Details

#argumentsObject



467
468
469
# File 'lib/syntax_tree/cli.rb', line 467

def arguments
  exists? ? File.readlines(filepath, chomp: true) : []
end

#exists?Boolean



463
464
465
# File 'lib/syntax_tree/cli.rb', line 463

def exists?
  File.readable?(filepath)
end