# File sample/psql.rb, line 338
def do_help(topic)
  if !topic
    printf("type \\h <cmd> where <cmd> is one of the following:\n")

    left_center_right = 'L' # Start with left column
    for i in 0..QL_HELP.length-1
      case left_center_right
      when  'L'
        printf("    %-25s", QL_HELP[i][0])
        left_center_right = 'C'

      when 'C'
        printf("%-25s", QL_HELP[i][0])
        left_center_right = 'R'

      when 'R'
        printf("%-25s\n", QL_HELP[i][0])
        left_center_right = 'L'

      end
    end
    if (left_center_right != 'L')
      STDOUT.print("\n")
    end
    printf("type \\h * for a complete description of all commands\n")
  else
    help_found = FALSE
    for i in 0..QL_HELP.length-1
      if QL_HELP[i][0] == topic || topic == "*"
        help_found = TRUE
        printf("Command: %s\n", QL_HELP[i][0])
        printf("Description: %s\n", QL_HELP[i][1])
        printf("Syntax:\n")
        printf("%s\n", QL_HELP[i][2])
        printf("\n")
      end
    end
    if !help_found
      printf("command not found, ")
      printf("try \\h with no arguments to see available help\n")
    end
  end
end