code: func NewCompleter(cs Commands) Completer {
  	return func(line string) string {
  		switch tokens := strings.Fields(line); len(tokens) {
  		case 0:
  			// Nothing to complete
  		case 1:
  			// Single token -- complete command name
  			found := ""
  			for c := range cs {
  				if strings.HasPrefix(c, tokens[0]) {
  					if found != "" {
  						return line
  					}
  					found = c
  				}
  			}
  			if found != "" {
  				return found
  			}
  		default:
  			// Multiple tokens -- complete using command completer
  			if c, ok := cs[tokens[0]]; ok {
  				if c.Complete != nil {
  					lastTokenIdx := len(tokens) - 1
  					lastToken := tokens[lastTokenIdx]
  					if strings.HasPrefix(lastToken, "-") {
  						lastToken = "-" + c.Complete(lastToken[1:])
  					} else {
  						lastToken = c.Complete(lastToken)
  					}
  					return strings.Join(append(tokens[:lastTokenIdx], lastToken), " ")
  				}
  			}
  		}
  		return line
  	}
  }
docs: // NewCompleter creates an autocompletion function for a set of commands.