class HabiticaCli::Config
Handles basic configuration parsing and interacts with Kefir for config storage
Public Class Methods
new(cli_options)
click to toggle source
# File lib/habitica_cli/config.rb, line 5 def initialize(cli_options) @options = cli_options @config = Kefir.config('habitica_cli') end
Public Instance Methods
usage()
click to toggle source
# File lib/habitica_cli/config.rb, line 23 def usage <<-ERR **Error**: You must provide a habit user and api key Do this via: - adding `habit_user` and `habit_key` to #{@config.path} - setting HABIT_USER and HABIT_KEY in your shell - passing --habit_user --habit_key ERR end
user_and_api_key()
click to toggle source
# File lib/habitica_cli/config.rb, line 10 def user_and_api_key config = Kefir.config('habitica_cli') habit_user = @options[:habit_user] || ENV['HABIT_USER'] habit_key = @options[:habit_key] || ENV['HABIT_KEY'] if blank?(habit_user) || blank?(habit_key) habit_user = config.get('habit_user') habit_key = config.get('habit_key') end [habit_user, habit_key] end
Private Instance Methods
blank?(obj)
click to toggle source
# File lib/habitica_cli/config.rb, line 35 def blank?(obj) # rubocop:disable Style/DoubleNegation obj.respond_to?(:empty?) ? !!obj.empty? : !obj # rubocop:enable Style/DoubleNegation end