CLI: include directory name in %-replacement.

pull/97/merge
whitequark 2017-01-24 19:54:44 +00:00
parent 67a916d19c
commit 27a5f6f9bd
1 changed files with 9 additions and 5 deletions

View File

@ -18,10 +18,10 @@ static void ShowUsage(const std::string &cmd) {
Common options: Common options:
-o, --output <pattern> -o, --output <pattern>
For an input file <basename>.slvs, replaces the '%%' symbol in <pattern> For an input file <name>.slvs, replaces the '%%' symbol in <pattern>
with <basename> and uses it as output file. For example, when using with <name> and uses it as output file. For example, when using
--output %%-2d.png for input files a.slvs and b.slvs, output files --output %%-2d.png for input files f/a.slvs and f/b.slvs, output files
a-2d.png and b-2d.png will be written. f/a-2d.png and f/b-2d.png will be written.
-v, --view <direction> -v, --view <direction>
Selects the camera direction. <direction> can be one of "top", "bottom", Selects the camera direction. <direction> can be one of "top", "bottom",
"left", "right", "front", "back", or "isometric". "left", "right", "front", "back", or "isometric".
@ -291,7 +291,11 @@ static bool RunCommand(const std::vector<std::string> args) {
std::string outputFile = outputPattern; std::string outputFile = outputPattern;
size_t replaceAt = outputFile.find('%'); size_t replaceAt = outputFile.find('%');
if(replaceAt != std::string::npos) { if(replaceAt != std::string::npos) {
outputFile.replace(replaceAt, 1, Basename(inputFile, /*stripExtension=*/true)); std::string outputSubst;
outputSubst = Dirname(inputFile);
outputSubst += PATH_SEP;
outputSubst += Basename(inputFile, /*stripExtension=*/true);
outputFile.replace(replaceAt, 1, outputSubst);
} }
std::string absOutputFile = PathFromCurrentDirectory(outputFile); std::string absOutputFile = PathFromCurrentDirectory(outputFile);