<commit_before>require 'optparse'
require 'pier/command'
require 'pier/moor/cd_dir_command'
require 'pier/moor/config_command'
require 'pier/moor/help_command'
require 'pier/moor/install_command'
require 'pier/moor/map_to_guest_workspace_command'
require 'pier/moor/proxy_command'
require 'pier/project_config'
require 'pier/workspace_config'
require 'shellwords'

module Pier
  class Moor
    include Command

    def initialize(cwd, argv)
      @argv = Array.new(argv)
      @workspace_config = WorkspaceConfig.new(cwd)
      @cwd = cwd
    end

    def run
      args = @argv.dup
      command = args.shift

      commands = {
        "install": lambda {
          return InstallCommand.new(@workspace_config, args)
        },
        "config": lambda {
          return ConfigCommand.new(@workspace_config, args, @cwd)
        },
        "docker-compose": lambda {
          return ProxyCommand.new('docker-compose', @workspace_config, args, @cwd)
        },
        "docker": lambda {
          return ProxyCommand.new('docker', @workspace_config, args, @cwd)
        },
        "map-to-guest-workspace": lambda {
          return MapToGuestWorkspaceCommand.new(@workspace_config, args)
        },
        "cd-dir": lambda {
          return CdDirCommand.new(@workspace_config, args, @cwd)
        },
        "help": lambda {
          HelpCommand.new
        },
      }

      command = :help if !command || !commands.key?(command.to_sym)

      cmd = commands[command.to_sym].call
      cmd.run
    end
  end
end<commit_msg>Display an error message when an invalid command is used<commit_after>require 'optparse'
require 'pier/command'
require 'pier/moor/cd_dir_command'
require 'pier/moor/config_command'
require 'pier/moor/help_command'
require 'pier/moor/install_command'
require 'pier/moor/map_to_guest_workspace_command'
require 'pier/moor/proxy_command'
require 'pier/project_config'
require 'pier/workspace_config'
require 'shellwords'

module Pier
  class Moor
    include Command

    def initialize(cwd, argv)
      @argv = Array.new(argv)
      @workspace_config = WorkspaceConfig.new(cwd)
      @cwd = cwd
    end

    def run
      args = @argv.dup
      command = args.shift

      commands = {
        "install": lambda {
          return InstallCommand.new(@workspace_config, args)
        },
        "config": lambda {
          return ConfigCommand.new(@workspace_config, args, @cwd)
        },
        "docker-compose": lambda {
          return ProxyCommand.new('docker-compose', @workspace_config, args, @cwd)
        },
        "docker": lambda {
          return ProxyCommand.new('docker', @workspace_config, args, @cwd)
        },
        "map-to-guest-workspace": lambda {
          return MapToGuestWorkspaceCommand.new(@workspace_config, args)
        },
        "cd-dir": lambda {
          return CdDirCommand.new(@workspace_config, args, @cwd)
        },
        "help": lambda {
          HelpCommand.new
        },
      }

      if command && !commands.key?(command.to_sym)
        puts "Invalid command: #{command}"
        command = "help"
      end

      command = :help if !command

      cmd = commands[command.to_sym].call
      cmd.run
    end
  end
end
{'fraction_non_alphanumeric': 0.11090284286160575, 'fraction_numerical': 0.0, 'mean_word_length': 2.538121546961326, 'pattern_counts': {'":': 14, '<': 3, '<?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': '60834', 'n_tokens_mistral': 1021, 'n_tokens_neox': 1000, 'n_words': 207}