Skip to content

Commit

Permalink
CLArgs: Parse frame ranges last, clarify doc
Browse files Browse the repository at this point in the history
frameRanges is a positional argument, and should thus be parsed last.
Should fix #644
  • Loading branch information
devernay committed Jul 5, 2021
1 parent 9d1b500 commit f530695
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Fix NodeGraph manipulation and navigation issues. #491 #627
- Fix Retina/High-DPI display issues on macOS, Windows and Linux/X11. #635
- Fix multi-dimensional parameter linking (bug introduced in 2.4.0 #594). #631
- Fix bug where any argument containing an integer between commas would be interpreted as a frame range. #644

### Plugins

Expand Down
47 changes: 23 additions & 24 deletions Engine/CLArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,30 +297,20 @@ CLArgs::printUsage(const std::string& programName)
" the command-line.\n\n"
"\n"
/* Text must hold in 80 columns ************************************************/
"Options for the execution of %1 projects:\n"
" %3 <project file path> [options]\n"
" -w [ --writer ] <Writer node script name> [<filename>] [<frameRange>]\n"
"Usage for the execution of %1 projects:\n"
" %3 <project file path> [options] [<frameRanges>]\n"
"Options/arguments:\n"
" -w [ --writer ] <Writer node script name> [<filename>]\n"
" Specify a Write node to render.\n"
" When in background mode, the renderer only renders the node script name\n"
" following this argument. If no such node exists in the project file, the\n"
" process will abort.\n"
" Note that if there is no --writer option, it renders all the writers in\n"
" the project.\n"
" After the writer node script name you can pass an optional output\n"
" filename and pass an optional frame range in the format:\n"
" <firstFrame>-<lastFrame> (e.g: 10-40).\n"
" The frame-range can also contain a frame-step indicating how many steps\n"
" the timeline should do before rendering a frame:\n"
" <firstFrame>-<lastFrame>:<frameStep> (e.g:1-10:2 Would render 1,3,5,7,9)\n"
" You can also specify multiple frame-ranges to render by separating them\n"
" with commas:\n"
" 1-10:1,20-30:2,40-50\n"
" Individual frames can also be specified:\n"
" 1329,2450,123,1-10:2\n"
" filename.\n"
" Note that several -w options can be set to specify multiple Write nodes\n"
" to render.\n"
" Note that if specified, the frame range is the same for all Write nodes\n"
" to render.\n"
" You may only specify absolute file paths to the writer optional filename.\n"
" -i [ --reader ] <reader node script name> <filename>\n"
" Specify the input file/sequence/video to load for the given Reader node.\n"
Expand All @@ -341,6 +331,15 @@ CLArgs::printUsage(const std::string& programName)
" This option is useful for debugging purposes or to control that a render\n"
" is working correctly.\n"
" **Please note** that it does not work when writing video files."
" <frameRanges>\n"
" One or more frame ranges, separated by commas.\n"
" Each frame range must be one of the following:\n"
" - <frame> (a single frame number, e.g. 57)\n"
" - <firstFrame>-<lastFrame> (e.g. 10-40)\n"
" - <firstFrame>-<lastFrame>:<frameStep> (e.g. 1-10:2 would render 1,3,5,7,9)\n"
" Examples:\n"
" 1-10:1,20-30:2,40-50\n"
" 1329,2450,123,1-10:2\n"
"Sample uses:\n"
" %1 /Users/Me/MyNatronProjects/MyProject.ntp\n"
" %1 -b -w MyWriter /Users/Me/MyNatronProjects/MyProject.ntp\n"
Expand Down Expand Up @@ -974,15 +973,6 @@ CLArgsPrivate::parse()
}
}

//Parse frame range
for (QStringList::iterator it = args.begin(); it != args.end(); ++it) {
if ( tryParseMultipleFrameRanges(*it, frameRanges) ) {
args.erase(it);
rangeSet = true;
break;
}
}

//Parse settings
for (;;) {
QStringList::iterator it = hasToken( QString::fromUtf8("setting"), QString() );
Expand Down Expand Up @@ -1225,6 +1215,15 @@ CLArgsPrivate::parse()
args.erase(it, endToErase);
}

//Parse frame range
for (QStringList::iterator it = args.begin(); it != args.end(); ++it) {
if ( tryParseMultipleFrameRanges(*it, frameRanges) ) {
args.erase(it);
rangeSet = true;
break;
}
}

if (atLeastOneOutput && !rangeSet) {
std::cout << tr("A frame range must be set when using the -o option").toStdString() << std::endl;
error = 1;
Expand Down

0 comments on commit f530695

Please sign in to comment.