package cmd import ( "fmt" "os" "mydev/internal/run" "github.com/spf13/cobra" ) // port wraps `lsof -i :` (the shell `portcheck`). No config needed. var portCmd = &cobra.Command{ Use: "port ", Short: "Show what is listening on a port (lsof -i :PORT)", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { // lsof exits 1 when nothing is on the port — report that plainly. if err := run.Stream("", "lsof", "-i", ":"+args[0]); err != nil { fmt.Printf("nothing listening on :%s\n", args[0]) os.Exit(1) } }, } func init() { rootCmd.AddCommand(portCmd) }