Class: Forward::Command::Config

Inherits:
Base
  • Object
show all
Defined in:
lib/forward/command/config.rb

Constant Summary collapse

CONFIGURABLE_SETTINGS =
%w[auto_copy auto_open].freeze
TRUTHY_REGEX =
/\A(?:true|t|yes|y|1)\z/i.freeze
FALESY_REGEX =
/\A(?:false|f|no|n|0)\z/i.freeze

Constants included from Forward::Common

Forward::Common::EMAIL_REGEX

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, run

Methods included from Forward::Common

#config, #exit_with_error, #exit_with_message, #logged_in?, #logger, #os, #stop_reactor_and_exit, #windows?

Constructor Details

This class inherits a constructor from Forward::Command::Base

Instance Method Details

#get(*args) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/forward/command/config.rb', line 29

def get(*args)
  @setting = args.first

  validate :setting
  config.load
  exit_with_message "#{@setting} is currently #{config.send(@setting)}"
end

#set(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/forward/command/config.rb', line 8

def set(*args)
  @setting = args[0]
  @value   = args[1]

  validate :setting, :value
  config.load
  config.send("#{@setting}=", @value)
  config.write
  exit_with_message "#{@setting} is now #{config.send(@setting)}"
end

#unset(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/forward/command/config.rb', line 19

def unset(*args)
  @setting = args.first

  validate :setting
  config.load
  default_value = config.set_default!(@setting)
  config.write
  exit_with_message "#{@setting} is now set to the default `#{default_value}'"
end