Skip to content

Commit

Permalink
cli: allow to pass file name as argument for load and dump
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Jan 5, 2018
1 parent aa8bf25 commit ac6e1df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/cayley/command/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ func NewLoadDatabaseCmd() *cobra.Command {
p := mustSetupProfile(cmd)
defer mustFinishProfile(p)
load, _ := cmd.Flags().GetString(flagLoad)
if load == "" && len(args) == 1 {
load = args[0]
}
if load == "" {
return errors.New("quads file must be specified")
return errors.New("one quads file must be specified")
}
if init, err := cmd.Flags().GetBool("init"); err != nil {
return err
Expand Down Expand Up @@ -135,8 +138,11 @@ func NewDumpDatabaseCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
printBackendInfo()
dump, _ := cmd.Flags().GetString(flagDump)
if dump == "" && len(args) == 1 {
dump = args[0]
}
if dump == "" {
return errors.New("quads file must be specified")
return errors.New("one quads file must be specified")
}
h, err := openDatabase()
if err != nil {
Expand Down

0 comments on commit ac6e1df

Please sign in to comment.