<commit_before>require 'alfred/task_manager'
require 'tasks/help_task'

module Alfred
  class Cli
    def run(argv)
      load_tasks

      if argv.empty?
        print_help
      else
        build_task(argv).run
      end
    end

    def load_tasks
      Alfred::TaskManager.load_tasks
    end

    def build_task(argv)
      arguments = argv.dup
      task_name = arguments.shift
      klazz     = Task.from_name(task_name)
      klazz.new(*klazz.parse_options!(arguments))
    rescue NameError
      task_not_found(task_name)
      exit(FALSE)
    rescue ArgumentError
      help(task_name)
      exit(FALSE)
    end

    def task_not_found(task_name)
      printf("Task '#{task_name}' not found\n\n")
      print_help
    end

    def help(task_name)
      printf("Wrong number of arguments.\n\n")
      HelpTask.run(task_name)
    end

    def print_help
      tasks = Alfred::TaskManager.tasks_by_name
      tasks.each { |task| print_task_line(task) }
    end
<commit_msg>Add a little header for the CLI summmary.<commit_after>require 'alfred/task_manager'
require 'tasks/help_task'

module Alfred
  class Cli
    HELP = <<-HELP
Alfred is a tool for making your life easier.

Available tasks:
HELP

    def run(argv)
      load_tasks

      if argv.empty?
        print_help
      else
        build_task(argv).run
      end
    end

    def load_tasks
      Alfred::TaskManager.load_tasks
    end

    def build_task(argv)
      arguments = argv.dup
      task_name = arguments.shift
      klazz     = Task.from_name(task_name)
      klazz.new(*klazz.parse_options!(arguments))
    rescue NameError
      task_not_found(task_name)
      exit(FALSE)
    rescue ArgumentError
      help(task_name)
      exit(FALSE)
    end

    def task_not_found(task_name)
      printf("Task '#{task_name}' not found\n\n")
      print_help
    end

    def help(task_name)
      printf("Wrong number of arguments.\n\n")
      HelpTask.run(task_name)
    end

    def print_help
      printf("%s", HELP)
      tasks = Alfred::TaskManager.tasks_by_name
      tasks.each { |task| print_task_line(task) }
    end

{'fraction_non_alphanumeric': 0.08325404376784015, 'fraction_numerical': 0.0, 'mean_word_length': 2.4250814332247557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4180280', 'n_tokens_mistral': 696, 'n_tokens_neox': 683, 'n_words': 151}