code: func newCompleter(fns []string) func(string) string {
  	return func(line string) string {
  		v := pprofVariables
  		switch tokens := strings.Fields(line); len(tokens) {
  		case 0:
  			// Nothing to complete
  		case 1:
  			// Single token -- complete command name
  			if match := matchVariableOrCommand(v, tokens[0]); match != "" {
  				return match
  			}
  		case 2:
  			if tokens[0] == "help" {
  				if match := matchVariableOrCommand(v, tokens[1]); match != "" {
  					return tokens[0] + " " + match
  				}
  				return line
  			}
  			fallthrough
  		default:
  			// Multiple tokens -- complete using functions, except for tags
  			if cmd := pprofCommands[tokens[0]]; cmd != nil && tokens[0] != "tags" {
  				lastTokenIdx := len(tokens) - 1
  				lastToken := tokens[lastTokenIdx]
  				if strings.HasPrefix(lastToken, "-") {
  					lastToken = "-" + functionCompleter(lastToken[1:], fns)
  				} else {
  					lastToken = functionCompleter(lastToken, fns)
  				}
  				return strings.Join(append(tokens[:lastTokenIdx], lastToken), " ")
  			}
  		}
  		return line
  	}
  }
docs: // newCompleter creates an autocompletion function for a set of commands.