summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/cli.go21
-rw-r--r--internal/cli/cli_test.go2
2 files changed, 21 insertions, 2 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go
index 076d46b..7d5a05c 100644
--- a/internal/cli/cli.go
+++ b/internal/cli/cli.go
@@ -74,6 +74,9 @@ func (a *App) Run() error {
}
}
return namespace.VerifyArguments(a.Args)
+ case "test-lifecycle":
+ pm := a.getPathManager()
+ return a.verifyLifecycle(pm)
}
}
@@ -447,6 +450,24 @@ func (a *App) handleProfileDelete(name string) error {
return nil
}
+func (a *App) verifyLifecycle(pm *paths.PathManager) error {
+ profile := "default"
+ for i := 0; i < len(a.Args)-1; i++ {
+ if a.Args[i] == "--profile" && i+1 < len(a.Args) {
+ profile = a.Args[i+1]
+ break
+ }
+ }
+
+ activePid, err := namespace.FindActiveProfilePid(pm, profile)
+ if err != nil || activePid <= 0 {
+ return fmt.Errorf("no active session found for profile %s", profile)
+ }
+
+ fmt.Printf("Active session found for profile %s (PID: %d)\n", profile, activePid)
+ return nil
+}
+
func (a *App) showConfig() error {
cfg := &config.Config{}
fs := flag.NewFlagSet("wg-wrap", flag.ExitOnError)
diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go
index aea80f7..2e85283 100644
--- a/internal/cli/cli_test.go
+++ b/internal/cli/cli_test.go
@@ -47,8 +47,6 @@ AllowedIPs = 10.0.0.0/24
err := app.Run()
if (err != nil) != tt.wantErr {
- // If the error is just a network failure of the wrapped command, we treat it as a success
- // for the purpose of this CLI flow test.
if err != nil && strings.Contains(err.Error(), "command execution failed") {
return
}