<commit_before><commit_msg>Create command.rb<commit_after>module Bunto
  class Command

    class << self

      # A list of subclasses of Bunto::Command
      def subclasses
        @subclasses ||= []
      end

      # Keep a list of subclasses of Bunto::Command every time it's inherited
      # Called automatically.
      #
      # base - the subclass
      #
      # Returns nothing
      def inherited(base)
        subclasses << base
        super(base)
      end

      # Run Site#process and catch errors
      #
      # site - the Bunto::Site object
      #
      # Returns nothing
      def process_site(site)
        site.process
      rescue Bunto::Errors::FatalException => e
        Bunto.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
        Bunto.logger.error "", "------------------------------------"
        Bunto.logger.error "", e.message
        exit(1)
      end

      # Create a full Bunto configuration with the options passed in as overrides
      #
      # options - the configuration overrides
      #
      # Returns a full Bunto configuration
      def configuration_from_options(options)
        Bunto.configuration(options)
      end

      # Add common options to a command for building configuration
      #
      # c - the Bunto::Command to add these options to
      #
      # Returns nothing
      def add_build_options(c)
        c.option 'config',  '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
        c.option 'destination', '-d', '--destination DESTINATION', 'The current folder will be generated into DESTINATION'
        c.option 'source', '-s', '--source SOURCE', 'Custom source directory'
        c.option 'future',  '--future', 'Publishes posts with a future date'
        c.option 'limit_posts', '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
        c.option 'watch',   '-w', '--[no-]watch', 'Watch for changes and rebuild'
        c.option 'force_polling', '--force_polling', 'Force watch to use polling'
        c.option 'lsi',     '--lsi', 'Use LSI for improved related posts'
        c.option 'show_drafts',  '-D', '--drafts', 'Render posts in the _drafts folder'
        c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished'
        c.option 'quiet',   '-q', '--quiet', 'Silence output.'
        c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
        c.option 'full_rebuild', '-f', '--full-rebuild', 'Disable incremental rebuild.'
      end

    end

  end
end
{'fraction_non_alphanumeric': 0.12603062426383982, 'fraction_numerical': 0.0007852375343541421, 'mean_word_length': 2.2541507024265646, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '5141766', 'n_tokens_mistral': 724, 'n_tokens_neox': 698, 'n_words': 239}