Skip to content

Commit 133a9cb

Browse files
2b3c5112b3c511
andauthored
Update export script prompt information (apache#14276)
* update export script prompt information * update export script prompt information * format --------- Co-authored-by: 2b3c511 <[email protected]>
1 parent fd105e0 commit 133a9cb

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportData.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ public static void main(String[] args) {
242242
true);
243243
System.exit(CODE_ERROR);
244244
}
245+
} else {
246+
ioTPrinter.println(
247+
String.format(
248+
"Invalid args: Required values for option '%s' not provided", FILE_TYPE_NAME));
249+
System.exit(CODE_ERROR);
245250
}
246251
int exitCode = CODE_OK;
247252
try {
@@ -531,6 +536,12 @@ private static void parseSpecialParams(CommandLine commandLine) throws ArgsError
531536
if (!targetDirectory.endsWith("/") && !targetDirectory.endsWith("\\")) {
532537
targetDirectory += File.separator;
533538
}
539+
final File file = new File(targetDirectory);
540+
if (!file.isDirectory()) {
541+
ioTPrinter.println(
542+
String.format("Source file or directory %s does not exist", targetDirectory));
543+
System.exit(CODE_ERROR);
544+
}
534545
if (commandLine.getOptionValue(LINES_PER_FILE_ARGS) != null) {
535546
linesPerFile = Integer.parseInt(commandLine.getOptionValue(LINES_PER_FILE_ARGS));
536547
}

iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportData.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ private static void parseSpecialParams(CommandLine commandLine) throws ArgsError
366366
}
367367
if (commandLine.getOptionValue(THREAD_NUM_ARGS) != null) {
368368
threadNum = Integer.parseInt(commandLine.getOptionValue(THREAD_NUM_ARGS));
369+
if (threadNum <= 0) {
370+
ioTPrinter.println(
371+
String.format(
372+
"error: Invalid thread number '%s'. Please set a positive integer.", threadNum));
373+
System.exit(CODE_ERROR);
374+
}
369375
}
370376
if (commandLine.getOptionValue(TIMESTAMP_PRECISION_ARGS) != null) {
371377
timestampPrecision = commandLine.getOptionValue(TIMESTAMP_PRECISION_ARGS);
@@ -512,16 +518,16 @@ public static void main(String[] args) throws IoTDBConnectionException {
512518
System.exit(CODE_ERROR);
513519
}
514520
} else {
515-
printHelpOptions(
516-
TSFILEDB_CLI_HEAD,
517-
TSFILEDB_CLI_PREFIX,
518-
hf,
519-
tsFileOptions,
520-
csvOptions,
521-
sqlOptions,
522-
true);
521+
ioTPrinter.println(
522+
String.format(
523+
"Invalid args: Required values for option '%s' not provided", FILE_TYPE_NAME));
523524
System.exit(CODE_ERROR);
524525
}
526+
} else {
527+
ioTPrinter.println(
528+
String.format(
529+
"Invalid args: Required values for option '%s' not provided", FILE_TYPE_NAME));
530+
System.exit(CODE_ERROR);
525531
}
526532

527533
try {

iotdb-client/cli/src/main/java/org/apache/iotdb/tool/tsfile/ExportTsFile.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ private static void parseSpecialParamsBack(CommandLine commandLine) throws ArgsE
252252
if (!targetDirectory.endsWith("/") && !targetDirectory.endsWith("\\")) {
253253
targetDirectory += File.separator;
254254
}
255+
final File file = new File(targetDirectory);
256+
if (!file.isDirectory()) {
257+
ioTPrinter.println(
258+
String.format("Source file or directory %s does not exist", targetDirectory));
259+
System.exit(CODE_ERROR);
260+
}
255261
}
256262

257263
/**

0 commit comments

Comments
 (0)