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,
  auto_fill_previous: true,
  preference_file: ::File.expand_path(
    ::File.join(ENV["HOME"], ".standuprc")
  )
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCli

Initializes the config with default values.



95
96
97
# File 'lib/standup_md/config/cli.rb', line 95

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)


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

def auto_fill_previous
  @auto_fill_previous
end

#dateDate

The date to use to find the entry.

Parameters:

  • date (Date)

Returns:

  • (Date)


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

def date
  @date
end

#editBoolean

Should the cli edit?

Parameters:

  • edit (Boolean)

Returns:

  • (Boolean)


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

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)


34
35
36
# File 'lib/standup_md/config/cli.rb', line 34

def editor
  @editor
end

#preference_fileString

The preference file for Cli.

Parameters:

  • preference (String)

Returns:

  • (String)


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

def preference_file
  @preference_file
end

Should the cli print the entry to the command line?

Parameters:

  • print (Boolean)

Returns:

  • (Boolean)


66
67
68
# File 'lib/standup_md/config/cli.rb', line 66

def print
  @print
end

#verboseBoolean

Should the cli print verbose output?

Parameters:

  • verbose (Boolean)

Returns:

  • (Boolean)


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

def verbose
  @verbose
end

#writeBoolean

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

Parameters:

  • write (Boolean)

Returns:

  • (Boolean)


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

def write
  @write
end

Instance Method Details

#resetHash

Sets all config values back to their defaults.

Returns:

  • (Hash)


103
104
105
# File 'lib/standup_md/config/cli.rb', line 103

def reset
  DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
end