Skip to content

Commit

Permalink
Add error handling for arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
kentaro-m committed May 5, 2017
1 parent 0eced20 commit 0f57843
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/copy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"errors"

"github.com/spf13/cobra"
"github.com/kentaro-m/md2confl/utils/util"
"github.com/kentaro-m/md2confl/utils/file"
Expand All @@ -15,6 +17,11 @@ var copyCmd = &cobra.Command{
}

func copy(cmd *cobra.Command, args []string) error {

if len(args) > 1 {
return errors.New("Too many arguments.")
}

file := file.File{}
if err := file.Open(args[0]); err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions cmd/preview.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"errors"

"github.com/spf13/cobra"
"github.com/kentaro-m/md2confl/confluence"
"github.com/kentaro-m/md2confl/utils/file"
Expand All @@ -14,6 +16,11 @@ var previewCmd = &cobra.Command{
}

func preview(cmd *cobra.Command, args []string) error {

if len(args) > 1 {
return errors.New("Too many arguments.")
}

file := file.File{}
if err := file.Open(args[0]); err != nil {
return err
Expand Down

0 comments on commit 0f57843

Please sign in to comment.