mydev/cmd/port.go
Victor Abrell 7140397a13 Initial commit: MyDev dev-environment TUI
CLI + live dashboard wrapping aws/docker/git/awsmfa for local dev:
AWS MFA auth status + expiry, dev compose stack control, container
drift vs the dev repo, git repo status, prod-data and DB-access tools.
Config-driven (~/.config/mydev/config.yaml). Dashboard runs commands
via a command palette with captured/interactive modes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 14:31:58 +02:00

29 lines
616 B
Go

package cmd
import (
"fmt"
"os"
"mydev/internal/run"
"github.com/spf13/cobra"
)
// port wraps `lsof -i :<port>` (the shell `portcheck`). No config needed.
var portCmd = &cobra.Command{
Use: "port <number>",
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)
}