Skip to content

Commit

Permalink
fix#2923 - Hop Run - Specify a custom separator char for parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sramazzina committed May 12, 2023
1 parent 36958a8 commit 11b76ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
15 changes: 11 additions & 4 deletions docs/hop-user-manual/modules/ROOT/pages/hop-run/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You'll see the option listed in a similar output to the one below:
----
Usage: <main class> [-ho] [-e=<environmentOption>] [-f=<filename>]
[-j=<projectOption>] [-l=<level>]
[-r=<runConfigurationName>] [-p=<parameters>[,
[-r=<runConfigurationName>] [-ps=<parametersSeparator] [-p=<parameters>[,
<parameters>...]]... [-s=<systemProperties>[,
<systemProperties>...]]...
-e, --environment=<environmentOption>
Expand All @@ -55,12 +55,15 @@ Usage: <main class> [-ho] [-e=<environmentOption>] [-f=<filename>]
-j, --project=<projectOption>
The name of the project to use
-l, --level=<level> The debug level, one of NOTHING, ERROR, MINIMAL, BASIC, DETAILED, DEBUG, ROWLEVEL
--logfile=<logFile> Write Hop console log to a file
-l, --level=<level> The debug level, one of NOTHING, ERROR, MINIMAL, BASIC, DETAILED, DEBUG, ROWLEVEL
-lf, --logfile=<logfile-name> The complete filename where hop-run will write the Hop console log
-m, --metadata-export=<metadataExportFile>
A file containing exported metadata in JSON format
-o, --printoptions Print the used options
-p, --parameters=<parameters>[,<parameters>...]
A comma separated list of PARAMETER=VALUE pairs
A list of PARAMETER=VALUE pairs
-ps, --parameters-separator=<parametersSeparator>
A character to be used as separator for our list of PARAMETER=VALUE pairs (default is ",").
-r, --runconfig=<runConfigurationName>
The name of the Run Configuration to use
-s, --system-properties=<systemProperties>[,<systemProperties>...]
Expand Down Expand Up @@ -97,7 +100,7 @@ Check the xref:projects/projects-environments.adoc[documentation on environments
|```-lf```
|```--logfile```
|Write Hop console log to a file specified by the user
|The complete filename where hop-run will write the Hop console log
|```-m```
|```--metadata-export```
Expand All @@ -111,6 +114,10 @@ Check the xref:projects/projects-environments.adoc[documentation on environments
|```--parameters```
|A comma separated list of PARAMETER=VALUE pairs
|```-ps```
|```--parameters-separator```
|A character to be used as separator for our list of PARAMETER=VALUE pairs (default is ",").
|```-r```
|```--runconfig```
|The name of the Run Configuration to use.
Expand Down
23 changes: 16 additions & 7 deletions engine/src/main/java/org/apache/hop/run/HopRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ public class HopRun implements Runnable, IHasHopMetadataProvider {

@Option(
names = {"-lf", "--logfile"},
description = "Write Hop console log to a file")
description = "The complete filename where hop-run will write the Hop console log")
private String logFile;

@Option(
names = {"-p", "--parameters"},
description = "A comma separated list of PARAMETER=VALUE pairs",
split = ",")
private String[] parameters = null;
description = "A list of PARAMETER=VALUE pairs")
private String parameters = null;

@Option(
names = {"-ps", "--parameters-separator"},
description = "A character to be used as separator for our list of PARAMETER=VALUE pairs (default is ,)" )
private String parametersSeparator = null;

@Option(
names = {"-s", "--system-properties"},
Expand Down Expand Up @@ -224,9 +228,11 @@ private void prepareInternalOptions(CommandLine cmd, String[] args) {
return;
}
}

String[] helpArgs = new String[args.length + 1];
System.arraycopy(args, 0, helpArgs, 0, args.length);
helpArgs[args.length] = "-h";

cmd.parseArgs(helpArgs);
}

Expand Down Expand Up @@ -473,8 +479,11 @@ private void parseParametersAndVariables(
INamedParameterDefinitions namedParams) {
try {
String[] availableParameters = namedParams.listParameters();

if (parameters != null) {
for (String parameter : parameters) {
parametersSeparator = parametersSeparator == null ? "," : parametersSeparator;

for (String parameter : parameters.split(parametersSeparator)) {
String[] split = parameter.split("=", 2);
String key = split.length > 0 ? split[0] : null;
String value = split.length > 1 ? split[1] : null;
Expand Down Expand Up @@ -665,14 +674,14 @@ public void setHelpRequested(boolean helpRequested) {
*
* @return value of parameters
*/
public String[] getParameters() {
public String getParameters() {
return parameters;
}

/**
* @param parameters The parameters to set
*/
public void setParameters(String[] parameters) {
public void setParameters(String parameters) {
this.parameters = parameters;
}

Expand Down

0 comments on commit 11b76ae

Please sign in to comment.