Class: Dsu::Subcommands::Config

Inherits:
BaseSubcommand show all
Defined in:
lib/dsu/subcommands/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dsu::Support::Ask

#ask_while, #yes?

Methods inherited from BaseCLI

date_option_description, #initialize, mnemonic_option_description

Methods included from Dsu::Support::TimesSortable

#sorted_dsu_times_for, #times_for, #times_sort

Methods included from Dsu::Support::CommandHookable

included

Methods included from Dsu::Support::CommandHelpColorizable

included

Methods included from Dsu::Support::ColorThemable

apply_theme, #prompt_with_options

Constructor Details

This class inherits a constructor from Dsu::BaseCLI

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dsu/subcommands/config.rb', line 16

def exit_on_failure?
  false
end

Instance Method Details

#deleteObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/dsu/subcommands/config.rb', line 45

def delete
  unless Models::Configuration.exist?
    messages = [I18n.t('messages.configuration_file.does_not_exist',
      configuration_file: Models::Configuration.config_file)]
    Views::Shared::Warning.new(messages: messages).render
    exit 1
  end
  Models::Configuration.delete!
  messages = [I18n.t('messages.configuration_file.deleted',
    configuration_file: Models::Configuration.config_file)]
  Views::Shared::Success.new(messages: messages).render
end

#infoObject



23
24
25
26
# File 'lib/dsu/subcommands/config.rb', line 23

def info
  configuration = Models::Configuration.new
  Views::Configuration::Show.new(config: configuration).call
end

#initObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dsu/subcommands/config.rb', line 31

def init
  exit 1 if configuration_errors_or_wanings?

  Models::Configuration.default.tap do |configuration|
    configuration.save!
    messages = [I18n.t('messages.configuration_file.created',
      configuration_file: Models::Configuration.config_file)]
    Views::Shared::Success.new(messages: messages).render
    Views::Configuration::Show.new(config: configuration).render
  end
end