<commit_before>module Mercenary
  class Command
    attr_reader :name
    attr_reader :description
    attr_reader :syntax
    attr_accessor :options
    attr_accessor :commands
    attr_accessor :actions
    attr_reader :map
    attr_accessor :parent

    # Public: Creates a new Command
    #
    # name - the name of the command
    # parent - (optional) the instancce of Mercenary::Command which you wish to
    #          be the parent of this command
    #
    # Returns nothing
    def initialize(name, parent = nil)
      @name = name
      @options = []
      @commands =  {}
      @actions = []
      @map = {}
      @parent = parent
    end

    # Public: Sets or gets the syntax string
    #
    # syntax - the string which describes this command's usage syntax (optional)
    #
    # Returns the syntax string and sets it if an argument is present
    def syntax(syntax = nil)
      @syntax = syntax if syntax
      @syntax
    end

    # Public: Sets or gets the command description
    #
    # description - the description of what the command does (optional)
    #
    # Returns the description and sets it if an argument is present
    def description(desc = nil)
      @description = desc if desc
      @description
    end

    # Public: Adds an option switch
    #
    # sym - the variable key which is used to identify the value of the switch
    #       at runtime in the options hash
    #
    # Returns nothing
    def option(sym, *options)
      @options << options
      @map[options[0]] = sym
    end

    # Public: Adds a subcommand
    #
    # cmd_name - the name of the command
    # block    - a block accepting the new instance of Mercenary::Command to be
    #            modified (optional)
    #
    # Returns nothing
    def command(cmd_name)
      cmd = Command.new(cmd_name, self)
      yield cmd
      @commands[cmd_name] = cmd
    end

    # Public: Add an alias for this command's name to be attached to the parent
    #
    # cmd_name - the name of the alias
    #
    # Returns nothing
    def alias(cmd_name)
      logger.debug "adding alias to parent for self: '#{cmd_name}'"
      @parent.commands[cmd_name] = self
    end

    # Public: Add an action Proc to be executed at runtime
    #
    # block - the Proc to be executed at runtime
    #
    # Returns nothing
    def action(&block)
      @actions << block
    end

    # Public: Fetch a Logger (stdlib)
    #
    # level - the logger level (a Logger constant, see docs for more info)
    #
    # Returns the instance of Logger
    def logger(level = Logger::DEBUG)<commit_msg>Bump default log level to INFO<commit_after>module Mercenary
  class Command
    attr_reader :name
    attr_reader :description
    attr_reader :syntax
    attr_accessor :options
    attr_accessor :commands
    attr_accessor :actions
    attr_reader :map
    attr_accessor :parent

    # Public: Creates a new Command
    #
    # name - the name of the command
    # parent - (optional) the instancce of Mercenary::Command which you wish to
    #          be the parent of this command
    #
    # Returns nothing
    def initialize(name, parent = nil)
      @name = name
      @options = []
      @commands =  {}
      @actions = []
      @map = {}
      @parent = parent
    end

    # Public: Sets or gets the syntax string
    #
    # syntax - the string which describes this command's usage syntax (optional)
    #
    # Returns the syntax string and sets it if an argument is present
    def syntax(syntax = nil)
      @syntax = syntax if syntax
      @syntax
    end

    # Public: Sets or gets the command description
    #
    # description - the description of what the command does (optional)
    #
    # Returns the description and sets it if an argument is present
    def description(desc = nil)
      @description = desc if desc
      @description
    end

    # Public: Adds an option switch
    #
    # sym - the variable key which is used to identify the value of the switch
    #       at runtime in the options hash
    #
    # Returns nothing
    def option(sym, *options)
      @options << options
      @map[options[0]] = sym
    end

    # Public: Adds a subcommand
    #
    # cmd_name - the name of the command
    # block    - a block accepting the new instance of Mercenary::Command to be
    #            modified (optional)
    #
    # Returns nothing
    def command(cmd_name)
      cmd = Command.new(cmd_name, self)
      yield cmd
      @commands[cmd_name] = cmd
    end

    # Public: Add an alias for this command's name to be attached to the parent
    #
    # cmd_name - the name of the alias
    #
    # Returns nothing
    def alias(cmd_name)
      logger.debug "adding alias to parent for self: '#{cmd_name}'"
      @parent.commands[cmd_name] = self
    end

    # Public: Add an action Proc to be executed at runtime
    #
    # block - the Proc to be executed at runtime
    #
    # Returns nothing
    def action(&block)
      @actions << block
    end

    # Public: Fetch a Logger (stdlib)
    #
    # level - the logger level (a Logger constant, see docs for more info)
    #
    # Returns the instance of Logger
    def logger(level = Logger::INFO)
{'fraction_non_alphanumeric': 0.06957866254348666, 'fraction_numerical': 0.00038654812524159255, 'mean_word_length': 2.222291407222914, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3185891', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1417, 'n_words': 586}