@@ -17,12 +17,13 @@ import (
// AddCmd creates a new person. Exported for potential use by shortcuts.
var AddCmd = &cobra.Command{
- Use: "add FIRST LAST",
+ Use: "add FIRST [LAST]",
Short: "Add a new person",
Long: `Add a new person to the Lunatask relationship tracker.
-Names are required. Use flags to set additional properties.`,- Args: cobra.ExactArgs(2),
+First name is required; last name is optional.
+Use flags to set additional properties.`,
+ Args: cobra.RangeArgs(1, 2),
RunE: runAdd,
}
@@ -36,7 +37,11 @@ func init() {
func runAdd(cmd *cobra.Command, args []string) error {
firstName := args[0]
- lastName := args[1]
+
+ lastName := ""
+ if len(args) > 1 {
+ lastName = args[1]
+ }
apiClient, err := client.New()
if err != nil {