Class: StandupMD::Config::Cli
- Inherits:
-
Object
- Object
- StandupMD::Config::Cli
- Defined in:
- lib/standup_md/config/cli.rb
Overview
The configuration class for StandupMD::Cli
Constant Summary collapse
- DEFAULTS =
The default options.
{ date: -> { Date.today }, editor: -> { ENV["VISUAL"] || ENV["EDITOR"] || "vim" }, verbose: false, edit: true, write: true, print: false, post: false, post_adapter: nil, post_channel: nil, auto_fill_previous: true, preference_file: ::File.( ::File.join(ENV["HOME"], ".standuprc") ) }.freeze
- CONFIG_ATTRIBUTES =
Attributes copied into request-scoped config snapshots.
DEFAULTS.keys.freeze
Instance Attribute Summary collapse
-
#auto_fill_previous ⇒ Boolean
When writing a new entry, should ‘previous’ be pulled from the last entry?.
-
#date ⇒ Date
The date to use to find the entry.
-
#edit ⇒ Boolean
Should the CLI edit?.
-
#editor ⇒ String
The editor to use when opening standup files.
-
#post ⇒ Boolean
Should the CLI post the entry to a chat client?.
-
#post_adapter ⇒ String, ...
The chat adapter to use for posting.
-
#post_channel ⇒ String?
The channel to use for posting.
-
#preference_file ⇒ String
The preference file for Cli.
-
#print ⇒ Boolean
Should the CLI print the entry to the command line?.
-
#verbose ⇒ Boolean
Should the CLI print verbose output?.
-
#write ⇒ Boolean
Should the CLI automatically write the new entry to the file?.
Instance Method Summary collapse
-
#copy_from(config) ⇒ StandupMD::Config::Cli
Copies values from another CLI config.
-
#initialize ⇒ Cli
constructor
Initializes the config with default values.
-
#reset ⇒ Hash
Sets all config values back to their defaults.
Constructor Details
#initialize ⇒ Cli
Initializes the config with default values.
128 129 130 |
# File 'lib/standup_md/config/cli.rb', line 128 def initialize reset end |
Instance Attribute Details
#auto_fill_previous ⇒ Boolean
When writing a new entry, should ‘previous’ be pulled from the last entry?
124 125 126 |
# File 'lib/standup_md/config/cli.rb', line 124 def auto_fill_previous @auto_fill_previous end |
#date ⇒ Date
The date to use to find the entry.
107 108 109 |
# File 'lib/standup_md/config/cli.rb', line 107 def date @date end |
#edit ⇒ Boolean
Should the CLI edit?
59 60 61 |
# File 'lib/standup_md/config/cli.rb', line 59 def edit @edit end |
#editor ⇒ String
The editor to use when opening standup files. If one is not set, the first of $VISUAL, $EDITOR, or vim will be used, in that order.
43 44 45 |
# File 'lib/standup_md/config/cli.rb', line 43 def editor @editor end |
#post ⇒ Boolean
Should the CLI post the entry to a chat client?
83 84 85 |
# File 'lib/standup_md/config/cli.rb', line 83 def post @post end |
#post_adapter ⇒ String, ...
The chat adapter to use for posting.
91 92 93 |
# File 'lib/standup_md/config/cli.rb', line 91 def post_adapter @post_adapter end |
#post_channel ⇒ String?
The channel to use for posting.
99 100 101 |
# File 'lib/standup_md/config/cli.rb', line 99 def post_channel @post_channel end |
#preference_file ⇒ String
The preference file for Cli.
115 116 117 |
# File 'lib/standup_md/config/cli.rb', line 115 def preference_file @preference_file end |
#print ⇒ Boolean
Should the CLI print the entry to the command line?
75 76 77 |
# File 'lib/standup_md/config/cli.rb', line 75 def print @print end |
#verbose ⇒ Boolean
Should the CLI print verbose output?
51 52 53 |
# File 'lib/standup_md/config/cli.rb', line 51 def verbose @verbose end |
#write ⇒ Boolean
Should the CLI automatically write the new entry to the file?
67 68 69 |
# File 'lib/standup_md/config/cli.rb', line 67 def write @write end |
Instance Method Details
#copy_from(config) ⇒ StandupMD::Config::Cli
Copies values from another CLI config.
148 149 150 151 152 153 154 155 156 |
# File 'lib/standup_md/config/cli.rb', line 148 def copy_from(config) CONFIG_ATTRIBUTES.each do |attribute| instance_variable_set( "@#{attribute}", copy_default(config.public_send(attribute)) ) end self end |
#reset ⇒ Hash
Sets all config values back to their defaults.
136 137 138 139 140 |
# File 'lib/standup_md/config/cli.rb', line 136 def reset DEFAULTS.each do |key, value| instance_variable_set("@#{key}", copy_default(resolve_default(value))) end end |