Class: StandupMD::Config::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/standup_md/config/cli.rb

Overview

The configuration class for StandupMD::Cli

Constant Summary collapse

DEFAULTS =

The default options.

Returns:

  • (Hash)
{
  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.expand_path(
    ::File.join(ENV["HOME"], ".standuprc")
  )
}.freeze
CONFIG_ATTRIBUTES =

Attributes copied into request-scoped config snapshots.

Returns:

  • (Array<Symbol>)
DEFAULTS.keys.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCli

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_previousBoolean

When writing a new entry, should ‘previous’ be pulled from the last entry?

Parameters:

  • auto_fill_previous (Boolean)

Returns:

  • (Boolean)


124
125
126
# File 'lib/standup_md/config/cli.rb', line 124

def auto_fill_previous
  @auto_fill_previous
end

#dateDate

The date to use to find the entry.

Parameters:

  • date (Date)

Returns:

  • (Date)


107
108
109
# File 'lib/standup_md/config/cli.rb', line 107

def date
  @date
end

#editBoolean

Should the CLI edit?

Parameters:

  • edit (Boolean)

Returns:

  • (Boolean)


59
60
61
# File 'lib/standup_md/config/cli.rb', line 59

def edit
  @edit
end

#editorString

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.

Parameters:

  • editor (String)

Returns:

  • (String)


43
44
45
# File 'lib/standup_md/config/cli.rb', line 43

def editor
  @editor
end

#postBoolean

Should the CLI post the entry to a chat client?

Parameters:

  • post (Boolean)

Returns:

  • (Boolean)


83
84
85
# File 'lib/standup_md/config/cli.rb', line 83

def post
  @post
end

#post_adapterString, ...

The chat adapter to use for posting.

Parameters:

  • post_adapter (String, Symbol, nil)

Returns:

  • (String, Symbol, nil)


91
92
93
# File 'lib/standup_md/config/cli.rb', line 91

def post_adapter
  @post_adapter
end

#post_channelString?

The channel to use for posting.

Parameters:

  • post_channel (String, nil)

Returns:

  • (String, nil)


99
100
101
# File 'lib/standup_md/config/cli.rb', line 99

def post_channel
  @post_channel
end

#preference_fileString

The preference file for Cli.

Parameters:

  • preference (String)

Returns:

  • (String)


115
116
117
# File 'lib/standup_md/config/cli.rb', line 115

def preference_file
  @preference_file
end

Should the CLI print the entry to the command line?

Parameters:

  • print (Boolean)

Returns:

  • (Boolean)


75
76
77
# File 'lib/standup_md/config/cli.rb', line 75

def print
  @print
end

#verboseBoolean

Should the CLI print verbose output?

Parameters:

  • verbose (Boolean)

Returns:

  • (Boolean)


51
52
53
# File 'lib/standup_md/config/cli.rb', line 51

def verbose
  @verbose
end

#writeBoolean

Should the CLI automatically write the new entry to the file?

Parameters:

  • write (Boolean)

Returns:

  • (Boolean)


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.

Parameters:

Returns:



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

#resetHash

Sets all config values back to their defaults.

Returns:

  • (Hash)


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