Skip to content

Commit

Permalink
feat(tgsql): CliArgument.getScript(): Added check invalid parameter
Browse files Browse the repository at this point in the history
FOLLOW UP: a86e4dd
  • Loading branch information
hishidama committed Mar 6, 2024
1 parent a86e4dd commit ecb68c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ public boolean getNoCommit() {
if (this.otherList == null || otherList.isEmpty()) {
throw new ParameterException("specify /path/to/script.sql");
}
if (otherList.size() > 1) {
throw new ParameterException(MessageFormat.format("contains invalid parameter {0}", otherList));
}
return otherList.get(0);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.tsurugidb.console.cli.config;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.EnumSet;

import javax.annotation.Nonnull;

import com.beust.jcommander.ParameterException;
import com.tsurugidb.console.cli.argument.CliArgument;
import com.tsurugidb.console.core.config.ScriptCommitMode;

Expand Down Expand Up @@ -62,6 +65,10 @@ private void fillScript() {
if (!Files.exists(script)) {
throw new FileNotFoundException(script.toString());
}
} catch (ParameterException e) {
throw e;
} catch (IOException e) {
throw new UncheckedIOException(/* e.getMessage(), */ e);
} catch (Exception e) {
throw new RuntimeException("invalid script", e);
}
Expand Down

0 comments on commit ecb68c2

Please sign in to comment.