Class: SyntaxTree::CLI::ConfigFile
- Inherits:
-
Object
- Object
- SyntaxTree::CLI::ConfigFile
- 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
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Instance Method Summary collapse
- #arguments ⇒ Object
- #exists? ⇒ Boolean
-
#initialize ⇒ ConfigFile
constructor
A new instance of ConfigFile.
Constructor Details
#initialize ⇒ ConfigFile
Returns a new instance of ConfigFile.
549 550 551 |
# File 'lib/syntax_tree/cli.rb', line 549 def initialize @filepath = File.join(Dir.pwd, FILENAME) end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
547 548 549 |
# File 'lib/syntax_tree/cli.rb', line 547 def filepath @filepath end |
Instance Method Details
#arguments ⇒ Object
557 558 559 |
# File 'lib/syntax_tree/cli.rb', line 557 def arguments exists? ? File.readlines(filepath, chomp: true) : [] end |
#exists? ⇒ Boolean
553 554 555 |
# File 'lib/syntax_tree/cli.rb', line 553 def exists? File.readable?(filepath) end |