def decode_command!(params_definition, arguments, auto_help, commands_stack=[])
      commands_definition = params_definition.first

      # Set the `command` variable only after; in the case where we print the help, this variable
      # must be unset.
      #
      command_for_check = arguments.shift

      # Note that `--help` is baked into OptParse, so without a workaround, we need to always include
      # it.
      #
      if command_for_check == '-h' || command_for_check == '--help'
        if auto_help
          throw :exit, ExitWithCommandsHelpPrinting.new(commands_definition)
        else
          # This is tricky. Since the common behavior of `--help` is to trigger an unconditional
          # help, it's not clear what to do with other tokens. For simplicity, we just return
          # this flag.
          #
          return { help: true }
        end
      end

      command = command_for_check

      raise InvalidCommand.new("Missing command") if command.nil?

      command_params_definition = commands_definition[command]

      case command_params_definition
      when nil
        raise InvalidCommand.new("Invalid command: #{command}")
      when Hash
        commands_stack << command

        # Nested case! Decode recursively
        #
        decode_command!([command_params_definition], arguments, auto_help, commands_stack)
      else
        commands_stack << command

        if command_params_definition.last.is_a?(Hash)
          internal_params = command_params_definition.pop # only long_help is here, if present
          @long_help = internal_params.delete(:long_help)
        end

        [
          compose_returned_commands(commands_stack),
          decode_arguments!(command_params_definition, arguments, auto_help, commands_stack),
        ]
      end
    end
def decode_command!(params_definition, arguments, auto_help, commands_stack=[])
      commands_definition = params_definition.first

      # Set the `command` variable only after; in the case where we print the help, this variable
      # must be unset.
      #
      command_for_check = arguments.shift

      # Note that `--help` is baked into OptParse, so without a workaround, we need to always include
      # it.
      #
      if command_for_check == '-h' || command_for_check == '--help'
        if auto_help
          throw :exit, ExitWithCommandsHelpPrinting.new(commands_definition)
        else
          # This is tricky. Since the common behavior of `--help` is to trigger an unconditional
          # help, it's not clear what to do with other tokens. For simplicity, we just return
          # this flag.
          #
          return { help: true }
        end
      end

      command = command_for_check

      raise InvalidCommand.new("Missing command") if command.nil?

      command_params_definition = commands_definition[command]

      case command_params_definition
      when nil
        raise InvalidCommand.new("Invalid command: #{command}")
      when Hash
        commands_stack << command

        # Nested case! Decode recursively
        #
        decode_command!([command_params_definition], arguments, auto_help, commands_stack)
      else
        commands_stack << command

        if command_params_definition.last.is_a?(Hash)
          internal_params = command_params_definition.pop # only long_help is here, if present
          @long_help = internal_params.delete(:long_help)
        end

        [
          compose_returned_commands(commands_stack),
          decode_arguments!(command_params_definition, arguments, auto_help, commands_stack),
        ]
      end
    end
MAIN CASES 
 Input params_definition for a non-nested case:

   [{"command1"=>["arg1", {:long_help=>"This is the long help."}], "command2"=>["arg2"]}]