Sha256: 610c2e0cd7308a91439551fb56b2652784d68a29b6549b6427b5adeb5ad97ede

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

# frozen_string_literal: true

require 'bundler'
require 'thor'
require_relative 'command_services/add_entry_service'
require_relative 'models/entry_group'
require_relative 'services/configuration_loader_service'
require_relative 'services/entry_group_hydrator_service'
require_relative 'services/entry_group_reader_service'
require_relative 'support/colorable'
require_relative 'support/configuration'
require_relative 'support/entry_group_viewable'
require_relative 'support/times_sortable'
require_relative 'version'
require_relative 'views/entry_group/show'

module Dsu
  class BaseCLI < ::Thor
    include Support::Colorable
    include Support::EntryGroupViewable
    include Support::TimesSortable

    class_option :debug, type: :boolean, default: false

    default_command :help

    class << self
      def exit_on_failure?
        false
      end

      def date_option_description
        <<-OPTION_DESC
          DATE:
          \x5
          This may be any date string that can be parsed using `Time.parse`. Consequently, you may use also use '/' as date separators, as well as omit thee year if the date you want to display is the current year (e.g. <month>/<day>, or 1/31). For example: `require 'time'; Time.parse('01/02/2023'); Time.parse('1/2') # etc.`
        OPTION_DESC
      end

      def mneumonic_option_description
        <<-OPTION_DESC
          MNEUMONIC:
          \x5
          This may be any of the following: DATE (see DATE)|n|today|t|tomorrow|y|yesterday.
        OPTION_DESC
      end
    end

    def initialize(*args)
      super

      @configuration = Services::ConfigurationLoaderService.new.call
    end

    private

    attr_reader :configuration

    def sorted_dsu_times_for(times:)
      times_sort(times: times_for(times: times), entries_display_order: entries_display_order)
    end

    def entries_display_order
      @entries_display_order ||= configuration[:entries_display_order]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dsu-1.1.0.alpha.1 lib/dsu/base_cli.rb