<commit_before>module Ctrlo
  module CLIErrors
    def error(message = nil)
      if message
        puts message
      else
        puts "No error message was given."
      end
    end
  end

  module CLI
    class Board < Thor
      include CLIErrors

      desc "all", "Show all the boards"
      def all
        Output.render(Ctrlo::Board.retrieve_all)
      end

      desc "current <board_id>", "Set the current board to <board_id>"
      def current(board_id)
        SetCurrent.for Ctrlo::Board.retrieve(board_id)
      end
    end

    class Card < Thor
      include CLIErrors

      desc "all", "Show all the cards for the current list or for <list_id>"
      def all(list_id = nil)
        if list_id
          Output.render(Ctrlo::List.retrieve(list_id).cards)
        else
          Output.render(Ctrlo::List.current.cards)
        end
      rescue => e
        error(e.message)
      end

      desc "current <card_id>", "Set the current card to <card_id>"
      def current(card_id)
        SetCurrent.for Ctrlo::Card.retrieve(card_id)
      end

      desc "show <card_id>", "Show a card <card_id> (includes comments)"
      def show(card_id)
        Ctrlo::Screen.render(Ctrlo::CardDecorator.decorate(Ctrlo::Card.retrieve(card_id)))
      end

      desc "comment", "Comment on a card with <card_id> <comment>"
      def comment(card_id, comment = nil)
        Ctrlo::CreateComment.for(card_id, comment)
      end

      desc "move", "Move a card <card_id> to list <list_id>"
      def move(card_id, list_id = nil)
        unless list_id
          Output.render(Ctrlo::Board.current.lists)
          error("Please choose a destination list. (Move a card <card_id> to list <list_id>)")
          exit 1
        end

        MoveCard.with(card_id, list_id)
      end
    end

    class List < Thor
      include CLIErrors

      desc "all", "Show all the lists the current board or for <board_id>"
      def all(board_id = nil)
        if board_id
          Output.render(Ctrlo::Board.retrieve(board_id).lists)
        else
          Output.render(Ctrlo::Board.current.lists)
        end
      rescue => e
        error(e.message)
      end

      desc "current <list_id>", "Set the current list to <list_id>"
      def current(list_id)
        SetCurrent.for Ctrlo::List.retrieve(list_id)
      end
    end

    class Main < Thor
      class_option :debug, type: :boolean, desc: "Enable debugging."

      desc "refresh", "Refresh all data"
      def refresh
        RefreshAll.perform
      end

      desc "cleanup", "Removes all local data"
      def cleanup
        DataMapper.auto_migrate!
      end

      desc "version", "Print the version"
      def version
        puts "ctrlo #{Ctrlo::VERSION}"
      end
<commit_msg>Rename CLIErrors to more universal Helpers.<commit_after>module Ctrlo
  module Helpers
    def notify(message = nil)
      puts message
    end

    def error(message = nil)
      if message
        puts message
      else
        puts "No error message was given."
      end
    end
  end

  module CLI
    class Board < Thor
      include Helpers

      desc "all", "Show all the boards"
      def all
        Output.render(Ctrlo::Board.retrieve_all)
      end

      desc "current <board_id>", "Set the current board to <board_id>"
      def current(board_id)
        SetCurrent.for Ctrlo::Board.retrieve(board_id)
      end
    end

    class Card < Thor
      include Helpers

      desc "all", "Show all the cards for the current list or for <list_id>"
      def all(list_id = nil)
        if list_id
          Output.render(Ctrlo::List.retrieve(list_id).cards)
        else
          Output.render(Ctrlo::List.current.cards)
        end
      rescue => e
        error(e.message)
      end

      desc "current <card_id>", "Set the current card to <card_id>"
      def current(card_id)
        SetCurrent.for Ctrlo::Card.retrieve(card_id)
      end

      desc "show <card_id>", "Show a card <card_id> (includes comments)"
      def show(card_id)
        Ctrlo::Screen.render(Ctrlo::CardDecorator.decorate(Ctrlo::Card.retrieve(card_id)))
      end

      desc "comment", "Comment on a card with <card_id> <comment>"
      def comment(card_id, comment = nil)
        Ctrlo::CreateComment.for(card_id, comment)
      end

      desc "move", "Move a card <card_id> to list <list_id>"
      def move(card_id, list_id = nil)
        unless list_id
          Output.render(Ctrlo::Board.current.lists)
          error("Please choose a destination list. (Move a card <card_id> to list <list_id>)")
          exit 1
        end

        MoveCard.with(card_id, list_id)
      end
    end

    class List < Thor
      include Helpers

      desc "all", "Show all the lists the current board or for <board_id>"
      def all(board_id = nil)
        if board_id
          Output.render(Ctrlo::Board.retrieve(board_id).lists)
        else
          Output.render(Ctrlo::Board.current.lists)
        end
      rescue => e
        error(e.message)
      end

      desc "current <list_id>", "Set the current list to <list_id>"
      def current(list_id)
        SetCurrent.for Ctrlo::List.retrieve(list_id)
      end
    end

    class Main < Thor
      include Helpers

      class_option :debug, type: :boolean, desc: "Enable debugging."

      desc "refresh", "Refresh all data"
      def refresh
        RefreshAll.perform
      end

      desc "cleanup", "Removes all local data"
      def cleanup
        DataMapper.auto_migrate!
        notify "All local data has been removed."
      end

      desc "version", "Print the version"
      def version
        puts "ctrlo #{Ctrlo::VERSION}"
      end

{'fraction_non_alphanumeric': 0.09094132246055664, 'fraction_numerical': 0.0003545470661230278, 'mean_word_length': 2.1519553072625697, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '79101', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1723, 'n_words': 514}