Skip to content

Commit b2f17cc

Browse files
authored
BUG: Fix argument handling in nxrunner (#1627)
1 parent 99f3a98 commit b2f17cc

2 files changed

Lines changed: 20 additions & 51 deletions

File tree

src/nxrunner/docs/NX_CLI.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ For example, ```--preflight D:/Directory/pipeline.d3pipeline -l D:/Logs/pipeline
4343
```bash
4444
--convert <pipeline filepath> [--logfile | -l]
4545
-c <pipeline filepath> [--logfile | -l]
46-
47-
--convert-output <pipeline filepath> [--logfile | -l]
48-
-co <pipeline filepath> [--logfile | -l]
4946
```
5047

51-
Converts a SIMPL pipeline at the target filepath to a simplnx pipeline. If any errors are encountered during the process, they are printed to the console. Otherwise, the converted pipeline is printed to the console. Optionally, a log file is created at the specified filepath where the output is saved.
48+
Converts a SIMPL pipeline at the target filepath to a simplnx pipeline. If any errors are encountered during the process, they are printed to the console. Optionally, a log file is created at the specified filepath where the output is saved.
5249

53-
The second option (convert-output / co) also saves the converted pipeline to file based on the name of the converted pipeline using the simplnx pipeline extension (`.d3pipeline`).
50+
The converted pipeline is saved to a file based on the name of the input pipeline using the simplnx pipeline extension (`.d3pipeline`).
5451

55-
For example, ```--convert-output D:/Directory/SIMPL.json``` will attempt to convert the SIMPL pipeline at `D:/Directory/SIMPL.json` and save the converted pipeline to `D:/Directory/SIMPL.d3pipeline`
52+
For example, ```--convert D:/Directory/SIMPL.json``` will attempt to convert the SIMPL pipeline at `D:/Directory/SIMPL.json` and save the converted pipeline to `D:/Directory/SIMPL.d3pipeline`

src/nxrunner/src/nxrunner.cpp

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ constexpr StringLiteral k_ExecuteParamLong = "--execute";
4747
constexpr StringLiteral k_PreflightParamLong = "--preflight";
4848
constexpr StringLiteral k_LogFileParamLong = "--logfile";
4949
constexpr StringLiteral k_ConvertParamLong = "--convert";
50-
constexpr StringLiteral k_ConvertOutputParamLong = "--convert-output";
5150

5251
constexpr StringLiteral k_HelpParamShort = "-h";
5352
constexpr StringLiteral k_ExecuteParamShort = "-e";
5453
constexpr StringLiteral k_PreflightParamShort = "-p";
5554
constexpr StringLiteral k_LogFileParamShort = "-l";
5655
constexpr StringLiteral k_ConvertParamShort = "-c";
57-
constexpr StringLiteral k_ConvertOutputParamShort = "-co";
5856

5957
void LoadApp()
6058
{
@@ -145,8 +143,7 @@ enum class ArgumentType
145143
Preflight,
146144
Help,
147145
Logfile,
148-
Convert,
149-
ConvertOutput
146+
Convert
150147
};
151148

152149
struct Argument
@@ -240,11 +237,6 @@ Result<CliArguments> ParseParameters(int argc, char* argv[])
240237
std::string argStr = ParseArgument(argc, argv, index);
241238
args.emplace_back(ArgumentType::Convert, argStr);
242239
}
243-
else if(arg == k_ConvertOutputParamLong || arg == k_ConvertOutputParamShort)
244-
{
245-
std::string argStr = ParseArgument(argc, argv, index);
246-
args.emplace_back(ArgumentType::ConvertOutput, argStr);
247-
}
248240
else
249241
{
250242
args.emplace_back(ArgumentType::Invalid, arg);
@@ -320,7 +312,7 @@ Result<> ExecutePipeline(const Argument& arg)
320312
if(pipelinePath.ends_with(".json"))
321313
{
322314
cliOut << "Input file '" << pipelinePath << "' is a legacy DREAM.3D version 6.x formatted pipeline.\n";
323-
cliOut << " You will need to run `nxrunner --convert-output [PATH TO .JSON FILE]` to first convert the\n";
315+
cliOut << " You will need to run `nxrunner --convert [PATH TO .JSON FILE]` to first convert the\n";
324316
cliOut << " pipeline file to the newer format. Please note that the conversion can fail as filters have\n";
325317
cliOut << " been updated and previous parameters may not be available in DREAM3D-NX.\n";
326318
return nx::core::ConvertResult(std::move(loadPipelineResult));
@@ -357,7 +349,7 @@ Result<> PreflightPipeline(const Argument& arg)
357349
if(pipelinePath.ends_with(".json"))
358350
{
359351
cliOut << "Input file '" << pipelinePath << "' is a legacy DREAM.3D version 6.x formatted pipeline.\n";
360-
cliOut << " You will need to run `nxrunner --convert-output [PATH TO .JSON FILE]` to first convert the\n";
352+
cliOut << " You will need to run `nxrunner --convert [PATH TO .JSON FILE]` to first convert the\n";
361353
cliOut << " pipeline file to the newer format. Please note that the conversion can fail as filters have\n";
362354
cliOut << " been updated and previous parameters may not be available in DREAM3D-NX.\n";
363355
return nx::core::ConvertResult(std::move(loadPipelineResult));
@@ -447,52 +439,44 @@ Result<> ConvertPipeline(const Argument& arg, bool printConvertedPipeline, bool
447439
void DisplayDefaultHelp()
448440
{
449441
cliOut << "Options:\n";
450-
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ExecuteParamLong, k_ExecuteParamShort, k_LogFileParamLong, k_LogFileParamShort)
451-
<< "\t Execute the pipeline at the target filepath. Optionally, create a log file at the specified path.\n";
452-
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_PreflightParamLong, k_PreflightParamShort, k_LogFileParamLong, k_LogFileParamShort)
453-
<< "\t Preflight the pipeline at the target filepath. Optionally, create a log file at the specified path.\n";
454-
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ConvertParamLong, k_ConvertParamShort, k_LogFileParamLong, k_LogFileParamShort)
455-
<< "\t Convert the SIMPL pipeline at the target filepath. Optionally, create a log file at the specified path.";
456-
cliOut << fmt::format("\t <operand [argument]> [{}|{} <log filepath>]\t", k_LogFileParamLong, k_LogFileParamShort) << "\t Creates a log file at the specified path.";
442+
cliOut << fmt::format(" {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ExecuteParamLong, k_ExecuteParamShort, k_LogFileParamLong, k_LogFileParamShort)
443+
<< " Execute the pipeline at the target filepath. Optionally, create a log file at the specified path.\n";
444+
cliOut << fmt::format(" {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_PreflightParamLong, k_PreflightParamShort, k_LogFileParamLong, k_LogFileParamShort)
445+
<< " Preflight the pipeline at the target filepath. Optionally, create a log file at the specified path.\n";
446+
cliOut << fmt::format(" {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ConvertParamLong, k_ConvertParamShort, k_LogFileParamLong, k_LogFileParamShort)
447+
<< " Convert the SIMPL pipeline at the target filepath. Optionally, create a log file at the specified path.";
448+
cliOut << fmt::format(" <operand [argument]> [{}|{} <log filepath>]\t", k_LogFileParamLong, k_LogFileParamShort) << " Creates a log file at the specified path.";
457449
cliOut.endline();
458450
}
459451

460452
void DisplayExecuteHelp()
461453
{
462454
cliOut << "To execute a target pipeline file:\n\t";
463-
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ExecuteParamLong, k_ExecuteParamShort, k_LogFileParamLong, k_LogFileParamShort)
464-
<< "\t Execute the pipeline at the target filepath. Optionally, create a log file at the specified path.";
455+
cliOut << fmt::format(" {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ExecuteParamLong, k_ExecuteParamShort, k_LogFileParamLong, k_LogFileParamShort)
456+
<< " Execute the pipeline at the target filepath. Optionally, create a log file at the specified path.";
465457
cliOut.endline();
466458
}
467459

468460
void DisplayPreflightHelp()
469461
{
470462
cliOut << "To preflight a target pipeline file:\n\t";
471-
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_PreflightParamLong, k_PreflightParamShort, k_LogFileParamLong, k_LogFileParamShort)
472-
<< "\t Preflight the pipeline at the target filepath. Optionally, create a log file at the specified path.";
463+
cliOut << fmt::format(" {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_PreflightParamLong, k_PreflightParamShort, k_LogFileParamLong, k_LogFileParamShort)
464+
<< " Preflight the pipeline at the target filepath. Optionally, create a log file at the specified path.";
473465
cliOut.endline();
474466
}
475467

476468
void DisplayConvertHelp()
477469
{
478470
cliOut << "To convert a target SIMPL pipeline file:\n\t";
479-
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ConvertParamLong, k_ConvertParamShort, k_LogFileParamLong, k_LogFileParamShort)
480-
<< "\t Convert the SIMPL pipeline at the target filepath. Optionally, create a log file at the specified path.";
481-
cliOut.endline();
482-
}
483-
484-
void DisplayConvertOutputHelp()
485-
{
486-
cliOut << "To convert and save a target SIMPL pipeline file:\n\t";
487-
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ConvertOutputParamLong, k_ConvertOutputParamShort, k_LogFileParamLong, k_LogFileParamShort)
488-
<< "\t Convert the SIMPL pipeline at the target filepath and saves the converted version with the updated extension. Optionally, create a log file at the specified path.";
471+
cliOut << fmt::format(" {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ConvertParamLong, k_ConvertParamShort, k_LogFileParamLong, k_LogFileParamShort)
472+
<< " Convert the SIMPL pipeline at the target filepath. Optionally, create a log file at the specified path.";
489473
cliOut.endline();
490474
}
491475

492476
void DisplayLogfileHelp()
493477
{
494478
cliOut << "To export output a log file:\n\t";
495-
cliOut << fmt::format("\t <operand [argument]> [{}|{} <log filepath>]\t", k_LogFileParamLong, k_LogFileParamShort) << "\t Creates a log file at the specified path.";
479+
cliOut << fmt::format(" <operand [argument]> [{}|{} <log filepath>]\t", k_LogFileParamLong, k_LogFileParamShort) << " Creates a log file at the specified path.";
496480
cliOut.endline();
497481
}
498482

@@ -517,10 +501,6 @@ Result<> DisplayHelpMenu(const std::vector<Argument>& arguments)
517501
DisplayConvertHelp();
518502
return {};
519503
}
520-
case ArgumentType::ConvertOutput: {
521-
DisplayConvertOutputHelp();
522-
return {};
523-
}
524504
case ArgumentType::Logfile: {
525505
DisplayLogfileHelp();
526506
return {};
@@ -586,9 +566,6 @@ int main(int argc, char* argv[])
586566
case ArgumentType::Convert: {
587567
[[fallthrough]];
588568
}
589-
case ArgumentType::ConvertOutput: {
590-
[[fallthrough]];
591-
}
592569
case ArgumentType::Execute: {
593570
[[fallthrough]];
594571
}
@@ -691,11 +668,6 @@ int main(int argc, char* argv[])
691668
break;
692669
}
693670
case ArgumentType::Convert: {
694-
auto result = ConvertPipeline(arguments[0], true, false);
695-
results.push_back(result);
696-
break;
697-
}
698-
case ArgumentType::ConvertOutput: {
699671
auto result = ConvertPipeline(arguments[0], false, true);
700672
results.push_back(result);
701673
break;

0 commit comments

Comments
 (0)