parent
9f5257ea59
commit
13f20a24f0
@ -0,0 +1,90 @@
|
|||||||
|
package com.wanhua.frameless.qp.stationv2.config;
|
||||||
|
|
||||||
|
import com.beust.jcommander.JCommander;
|
||||||
|
import com.beust.jcommander.Parameter;
|
||||||
|
import com.beust.jcommander.ParameterException;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Argument {
|
||||||
|
@Parameter(
|
||||||
|
names = "--stationId",
|
||||||
|
description = "station Id to sync, using station name",
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
private String stationId;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = "--city",
|
||||||
|
description = "city name to sync",
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = "--om",
|
||||||
|
description = "om name to sync",
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
private String om;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = "--tm",
|
||||||
|
description = "tm name to sync",
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
private String tm;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = "--startTime",
|
||||||
|
description = "startTime to sync, yyyy-MM-dd",
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = "--endTime",
|
||||||
|
description = "endTime to sync, yyyy-MM-dd",
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = "--clearDataFirst",
|
||||||
|
description = "clear data first",
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
private boolean clearDataFirst;
|
||||||
|
|
||||||
|
|
||||||
|
public static Argument parseAgument(String args) throws ParameterException {
|
||||||
|
Argument jArgs = new Argument();
|
||||||
|
JCommander cmd = JCommander.newBuilder()
|
||||||
|
.addObject(jArgs)
|
||||||
|
.build();
|
||||||
|
cmd.parse(args);
|
||||||
|
|
||||||
|
if (jArgs.stationId == null && jArgs.city == null && jArgs.om == null && jArgs.tm == null) {
|
||||||
|
throw new ParameterException("stationId or city or om or tm must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jArgs.stationId != null && (jArgs.city != null || jArgs.om != null || jArgs.tm != null)) {
|
||||||
|
throw new ParameterException("stationId and city or om or tm can not be set together");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jArgs.city != null && (jArgs.om != null || jArgs.tm != null)) {
|
||||||
|
throw new ParameterException("city and om or tm can not be set together");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jArgs.om != null && jArgs.tm != null) {
|
||||||
|
throw new ParameterException("om and tm can not be set together");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jArgs.startTime != null && jArgs.endTime == null || jArgs.endTime != null && jArgs.startTime == null) {
|
||||||
|
throw new ParameterException("startTime or endTime must be set together");
|
||||||
|
}
|
||||||
|
return jArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue