Class: Dsu::CLI
- Defined in:
- lib/dsu/cli.rb
Overview
The ‘dsu` command.
Constant Summary
Constants included from Support::CommandOptions::TimeMnemonics
Support::CommandOptions::TimeMnemonics::RELATIVE_REGEX, Support::CommandOptions::TimeMnemonics::TODAY, Support::CommandOptions::TimeMnemonics::TOMORROW, Support::CommandOptions::TimeMnemonics::YESTERDAY
Instance Method Summary collapse
Methods included from Support::TimeFormatable
dd_mm_yyyy, formatted_time, mm_dd, mm_dd_yyyy, timezone_for, yyyy_mm_dd, yyyy_mm_dd_or_through_for
Methods included from Support::CommandOptions::TimeMnemonic
relative_time_mnemonic?, time_from_mnemonic, time_from_mnemonic!, time_mnemonic?
Methods inherited from BaseCLI
date_option_description, exit_on_failure?, #initialize, mnemonic_option_description
Methods included from Support::TimesSortable
#sorted_dsu_times_for, #times_for, #times_sort
Methods included from Support::CommandHookable
Methods included from Support::CommandHelpColorizable
Methods included from Support::ColorThemable
apply_theme, #prompt_with_options
Constructor Details
This class inherits a constructor from Dsu::BaseCLI
Instance Method Details
#add(description) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/dsu/cli.rb', line 48 def add(description) date_or_mnemonic = if [I18n.t('options.date.name')].present? [I18n.t('options.date.name')] elsif [I18n.t('options.tomorrow.name')].present? I18n.t('options.tomorrow.name') elsif [I18n.t('options.yesterday.name')].present? I18n.t('options.yesterday.name') elsif [I18n.t('options.today.name')].present? I18n.t('options.today.name') end time = if time_mnemonic?(date_or_mnemonic) time_from_mnemonic(command_option: date_or_mnemonic) else Time.parse(date_or_mnemonic) end entry = Models::Entry.new(description: description) CommandServices::AddEntryService.new(entry: entry, time: time).call presenter = Presenters::EntryGroup::List::DatePresenter.new(times: [time], options: ) # TODO: Refactor View::EntryGroup::Show to accept a presenter and use it here Views::EntryGroup::List.new(presenter: presenter).render rescue ArgumentError => e Views::Shared::Error.new(messages: e.).render end |
#info ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/dsu/cli.rb', line 100 def info configuration_version = Models::Configuration::VERSION entry_group_version = Models::EntryGroup::VERSION color_theme_version = Models::ColorTheme::VERSION info = I18n.t('commands.info.info', dsu_version: dsu_version, configuration_version: configuration_version, entry_group_version: entry_group_version, color_theme_version: color_theme_version, config_folder: Support::Fileable.config_path, root_folder: Support::Fileable.root_folder, entries_folder: Support::Fileable.entries_folder, themes_folder: Support::Fileable.themes_folder, gem_folder: Support::Fileable.gem_dir, temp_folder: Support::Fileable.temp_folder, migration_version_folder: Support::Fileable.migration_version_folder, migration_file_folder: Support::Fileable.migration_version_path) puts apply_theme(info, theme_color: color_theme.body) end |
#version ⇒ Object
121 122 123 |
# File 'lib/dsu/cli.rb', line 121 def version puts apply_theme(dsu_version, theme_color: color_theme.body) end |