def parse(args)
      if args[0] =~ /^(--help|help)$/
        first, *rest = args
        if rest.empty?
          puts banner
        else
          puts commands[rest.first].help
        end
      elsif cmd = args.find { |el| commands.has_command?(el) }
        cmd_idx = args.index(cmd)
        top_args, cmd_args = args.partition.with_index do |_arg, idx|
          idx < cmd_idx
        end
        top.parse(top_args)
        remainder = commands[cmd].parse(cmd_args[1..-1])
      else
        if args.empty?
          puts banner
        else
          remainder = top.parse(args)
        end
      end

      [cmd || name, arguments, remainder || []]
    end
def parse(args)
      if args[0] =~ /^(--help|help)$/
        first, *rest = args
        if rest.empty?
          puts banner
        else
          puts commands[rest.first].help
        end
      elsif cmd = args.find { |el| commands.has_command?(el) }
        cmd_idx = args.index(cmd)
        top_args, cmd_args = args.partition.with_index do |_arg, idx|
          idx < cmd_idx
        end
        top.parse(top_args)
        remainder = commands[cmd].parse(cmd_args[1..-1])
      else
        if args.empty?
          puts banner
        else
          remainder = top.parse(args)
        end
      end

      [cmd || name, arguments, remainder || []]
    end
TODO: Extract this method into separate class that gives all
 the involved parties the chance to parse all of the args