Skip to content

Commit 0f57843

Browse files
committed
Add error handling for arguments.
1 parent 0eced20 commit 0f57843

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

cmd/copy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cmd
22

33
import (
4+
"errors"
5+
46
"github.com/spf13/cobra"
57
"github.com/kentaro-m/md2confl/utils/util"
68
"github.com/kentaro-m/md2confl/utils/file"
@@ -15,6 +17,11 @@ var copyCmd = &cobra.Command{
1517
}
1618

1719
func copy(cmd *cobra.Command, args []string) error {
20+
21+
if len(args) > 1 {
22+
return errors.New("Too many arguments.")
23+
}
24+
1825
file := file.File{}
1926
if err := file.Open(args[0]); err != nil {
2027
return err

cmd/preview.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cmd
22

33
import (
4+
"errors"
5+
46
"github.com/spf13/cobra"
57
"github.com/kentaro-m/md2confl/confluence"
68
"github.com/kentaro-m/md2confl/utils/file"
@@ -14,6 +16,11 @@ var previewCmd = &cobra.Command{
1416
}
1517

1618
func preview(cmd *cobra.Command, args []string) error {
19+
20+
if len(args) > 1 {
21+
return errors.New("Too many arguments.")
22+
}
23+
1724
file := file.File{}
1825
if err := file.Open(args[0]); err != nil {
1926
return err

0 commit comments

Comments
 (0)