feat: added kill session command

This commit is contained in:
raj 2023-10-23 01:22:07 +05:30
parent 6a4ac440b0
commit 0f3dfb20cc
2 changed files with 27 additions and 0 deletions

View File

@ -217,3 +217,12 @@ func createWindow(config *projectconfig.Configuration, sessionName string, index
return nil
}
func KillTmuxSession(sessionName string) error {
killSessionCmd := exec.Command("tmux", "kill-session", "-t", sessionName)
if err := killSessionCmd.Run(); err != nil {
return err
}
log.Debug("Ran command", "command", killSessionCmd.String())
return nil
}

View File

@ -16,6 +16,24 @@ var RootCmd = &cobra.Command{
},
}
var KillTmuxSessionCmd = &cobra.Command{
Use: "kill",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
sessionName := args[0]
err := controller.KillTmuxSession(sessionName)
if err != nil {
log.Error(err)
return
}
log.Debug("Killed tmux session", "name", sessionName)
},
}
func init() {
RootCmd.AddCommand(KillTmuxSessionCmd)
}
func ExecuteProjectEnv(projectName string) {
config, err := projectconfig.GetProjectConfig(projectName)
if err != nil {