Class: AirtableBaseBuilder::Config

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/airtable_base_builder/config.rb

Constant Summary collapse

VALID_OPTIONS =
%w[pat workspace_id].freeze

Instance Method Summary collapse

Instance Method Details

#add_option(option, value) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/airtable_base_builder/config.rb', line 9

def add_option(option, value)
  # TODO: Handle this option validation with thor conventions
  unless VALID_OPTIONS.include?(option)
    say_error("Option must be one of: #{VALID_OPTIONS.join(', ')}", color = :red)
    exit
  end

  unless File.directory?('config')
    say("Creating `config/` directory", color = :green)
    empty_directory('config')
  end

  if File.exist?("config/#{option}.txt")
    say("Removing old `config/#{option}.txt`", color = :green)
    remove_file("config/#{option}.txt")
  end

  say("Creating `config/#{option}.txt` to store your value", color = :green)
  create_file("config/#{option}.txt", value)
end

#patObject



30
31
32
# File 'lib/airtable_base_builder/config.rb', line 30

def pat
  File.read("config/pat.txt")
end

#workspace_idObject



34
35
36
# File 'lib/airtable_base_builder/config.rb', line 34

def workspace_id
  File.read("config/workspace_id.txt")
end