Class: AirtableBaseBuilder::Config
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- AirtableBaseBuilder::Config
- 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 |
#pat ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/airtable_base_builder/config.rb', line 30 def pat File.read("config/pat.txt") rescue Errno::ENOENT say_error("\n\nYou must set your Personal Access Token first", color = :red) at_link = set_color("https://airtable.com/account", :blue, :bold) say("If you do not have a Personal Access Token, you can create one here: #{at_link}", color = :green) command = set_color("`atbb config pat YOUR_TOKEN`", color = :magenta, :bold) say( "\nOnce you have your Personal Access Token, run #{command}\n\n", color = :green ) end |
#workspace_id ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/airtable_base_builder/config.rb', line 43 def workspace_id File.read("config/workspace_id.txt") rescue Errno::ENOENT say_error("\n\nYou must set a Workspace ID in which to create bases first", color = :red) say("You can find your Workspace ID in the URL of your Airtable Workspace", color = :green) at_link = set_color("https://airtable.com/workspaces/wsp*******?", :blue, :bold) say( "From the Airtable homepage, click on your Workspace, and copy the ID from the URL It will look something like this: #{at_link} The ID is the part that starts with `wsp` and is a long string of letters and numbers (but does not include the `?`).", color = :green ) command = set_color("`atbb config workspace_id YOUR_ID`", color = :magenta, :bold) say( "\nOnce you have your Workspace ID, run #{command}\n\n", color = :green ) end |