From 47a184b89cae0463dd17c8c0c48ae25ec690377e Mon Sep 17 00:00:00 2001 From: James Walker Date: Thu, 30 Jul 2020 22:37:16 -0400 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20make=20use=20of=20command?= =?UTF-8?q?=20Args?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/list.go | 2 +- cmd/new.go | 5 +---- cmd/start.go | 8 +------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index db4aaec..e5b3e90 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -32,7 +32,7 @@ import ( var listCmd = &cobra.Command{ Use: "list", Short: "A brief description of your command", - Long: "", + Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { err := tmux.ListProjects() if err != nil { diff --git a/cmd/new.go b/cmd/new.go index f31e970..5a48923 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -32,11 +32,8 @@ import ( var newCmd = &cobra.Command{ Use: "new [NAME]", Short: "Create a new project", + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - if len(args) < 1 { - fmt.Println("Provide a project name") - return - } err := tmux.NewProject(args[0]) if err != nil { fmt.Println("Unable to create project:", err) diff --git a/cmd/start.go b/cmd/start.go index 8a556e7..68881f0 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -22,8 +22,6 @@ THE SOFTWARE. package cmd import ( - "fmt" - "github.com/spf13/cobra" "github.com/walkah/workon/tmux" ) @@ -32,12 +30,8 @@ import ( var startCmd = &cobra.Command{ Use: "start [PROJECT]", Short: "Start working on a project", - Long: "", + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - if len(args) < 1 { - fmt.Println("No project given") - return - } tmux.StartProject(args[0]) }, }