code: func main() {
  	var err error
  	// Parse flag and initialize logging
  	flag.Parse()
  	if os.Getenv("STAGE1_DEBUG") == "true" {
  		debug = true
  	}
  	stage1initcommon.InitDebug(debug)
  	log, diag, _ = rktlog.NewLogSet("iottymux", debug)
  	if !debug {
  		diag.SetOutput(ioutil.Discard)
  	}
  
  	// validate app name
  	_, err = types.NewACName(appName)
  	if err != nil {
  		log.Printf("invalid app name (%s): %v", appName, err)
  		os.Exit(254)
  	}
  
  	var r error
  	statusFile := filepath.Join(pathPrefix, appName, "endpoints")
  
  	// TODO(lucab): split this some more. Mux is part of pod service,
  	// while other actions are called from stage0. Those should be split.
  	switch action {
  	// attaching
  	case "auto-attach":
  		r = actionAttach(statusFile, true)
  	case "custom-attach":
  		r = actionAttach(statusFile, false)
  
  	// muxing and proxying
  	case "iomux":
  		r = actionIOMux(statusFile)
  	case "ttymux":
  		r = actionTTYMux(statusFile)
  
  	// listing
  	case "list":
  		r = actionPrint(statusFile, os.Stdout)
  
  	default:
  		r = fmt.Errorf("unknown action %q", action)
  	}
  
  	if r != nil && r != io.EOF {
  		log.FatalE("runtime failure", r)
  	}
  	os.Exit(0)
  }
docs: // iottymux is a multi-action binary which can be used for:
  //  * creating and muxing a TTY for an application
  //  * proxying streams for an application (stdin/stdout/stderr) over TCP
  //  * listing available attachable endpoints for an application