🐛 only list/stop active projects

Close #8
This commit is contained in:
2021-12-19 17:00:40 -05:00
parent fc05aed4c0
commit 5825a1b2b4
5 changed files with 27 additions and 17 deletions

View File

@ -34,10 +34,14 @@ var listCmd = &cobra.Command{
Short: "A brief description of your command",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
err := tmux.ListProjects()
projects, err := tmux.ListProjects()
if err != nil {
fmt.Println("Unable to list projects:", err)
}
for _, project := range projects {
fmt.Println(project)
}
},
}

View File

@ -33,11 +33,14 @@ var psCmd = &cobra.Command{
Use: "ps",
Short: "List currently running projects.",
Run: func(cmd *cobra.Command, args []string) {
t := tmux.Tmux{}
for _, project := range t.ListSessions() {
fmt.Println(project)
projects, err := tmux.ListActiveProjects()
if err != nil {
fmt.Println(err)
}
for _, project := range projects {
fmt.Println(project)
}
},
}

View File

@ -44,7 +44,7 @@ var rootCmd = &cobra.Command{
Long: "",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("No project or command given")
return errors.New("no project or command given")
}
startCmd.Run(cmd, args)
return nil
@ -54,7 +54,7 @@ var rootCmd = &cobra.Command{
}
func completeProjects(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
projects, err := tmux.ProjectList()
projects, err := tmux.ListProjects()
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}

View File

@ -36,8 +36,7 @@ var stopCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
var projects []string
if len(args) == 0 {
t := tmux.Tmux{}
projects = t.ListSessions()
projects, _ = tmux.ListActiveProjects()
} else {
projects = args
}