lib/standup_md/config/cli.rb in standup_md-0.3.2 vs lib/standup_md/config/cli.rb in standup_md-0.3.3
- old
+ new
@@ -1,15 +1,33 @@
# frozen_string_literal: true
+
require 'date'
module StandupMD
class Config
##
# The configuration class for StandupMD::Cli
class Cli
+
##
+ # The default options.
+ #
+ # @return [Hash]
+ DEFAULTS = {
+ date: Date.today,
+ editor: ENV['VISUAL'] || ENV['EDITOR'] || 'vim',
+ verbose: false,
+ edit: true,
+ write: true,
+ print: false,
+ auto_fill_previous: true,
+ preference_file:
+ ::File.expand_path(::File.join(ENV['HOME'], '.standuprc')),
+ }
+
+ ##
# 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.
#
# @param [String] editor
#
@@ -31,27 +49,27 @@
#
# @return [Boolean]
attr_accessor :edit
##
- # Should the cli write the file?
+ # Should the cli automatically write the new entry to the file?
#
# @param [Boolean] write
#
# @return [Boolean]
attr_accessor :write
##
- # Should the cli print the entry?
+ # Should the cli print the entry to the command line?
#
# @param [Boolean] print
#
# @return [Boolean]
attr_accessor :print
##
- # The date to use to find the file.
+ # The date to use to find the entry.
#
# @param [Date] date
#
# @return [Date]
attr_accessor :date
@@ -80,27 +98,12 @@
end
##
# Sets all config values back to their defaults.
#
- # @return [Boolean] true if successful
+ # @return [Hash]
def reset
- @date = Date.today
- @editor = set_editor
- @verbose = false
- @edit = true
- @write = true
- @print = false
- @auto_fill_previous = true
- @preference_file = ::File.expand_path(::File.join(ENV['HOME'], '.standuprc'))
- end
-
- private
-
- def set_editor # :nodoc:
- return ENV['VISUAL'] if ENV['VISUAL']
- return ENV['EDITOR'] if ENV['EDITOR']
- 'vim'
+ DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
end
end
end
end