From 2494c745761e17d5ad92dbbed4de8d4124db39fd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 1 Nov 2013 21:32:24 +0300 Subject: in dyecmd add support for 2 and 3 parameters. Example: ./dyecmd cottonshirt.png W:#a4b2b2,ffffff test.png ./dyecmd "cottonshirt.png|W:#a4b2b2,ffffff" test2.png --- src/dyetool/dyemain.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/dyetool/dyemain.cpp') diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp index 3199a5c49..fe7ad0588 100644 --- a/src/dyetool/dyemain.cpp +++ b/src/dyetool/dyemain.cpp @@ -46,13 +46,14 @@ int serverVersion = 0; static void printHelp() { - std::cout << _("dyecmd srcfile dyestring dstfile") - << std::endl << std::endl; + std::cout << _("dyecmd srcfile dyestring dstfile") << std::endl; + std::cout << _("or") << std::endl; + std::cout << _("dyecmd srcdyestring dstfile") << std::endl; } int main(int argc, char **argv) { - if (argc != 4) + if (argc < 3 || argc > 4) printHelp(); logger = new Logger; @@ -73,13 +74,24 @@ int main(int argc, char **argv) resman->setWriteDir("."); resman->addToSearchPath(".", false); resman->addToSearchPath("/", false); - Image *image = resman->getImage(std::string( - argv[1]).append("|").append(argv[2])); + std::string src = argv[1]; + std::string dst; + if (argc == 4) + { + src.append("|").append(argv[2]); + dst = argv[3]; + } + else + { + dst = argv[2]; + } + + Image *image = resman->getImage(src); if (!image) { printf("Error loading image\n"); return 1; } - ImageWriter::writePNG(image->getSDLSurface(), argv[3]); + ImageWriter::writePNG(image->getSDLSurface(), dst); return 0; } -- cgit v1.2.3-70-g09d2