On 2011-09-08, Richard Heck wrote: > On 09/08/2011 01:57 PM, Julien Rioux wrote: >> On 08/09/2011 7:34 PM, Tommaso Cucinotta wrote: >>> Hi,
>>> would it be possible to add to LyX the possibility to specify an >>> explicit output file-name when exporting from the command-line to a >>> different format ? >>> Something along the line of: >>> lyx -e latex -o /path/to/output.tex /path/to/input.lyx >> http://www.lyx.org/trac/ticket/4501 > Presumably what is needed here is a "buffer-export-as" LFUN. But making > this work naturally from the command line will be trickier than it > looks. In effect, "-e pdf" is just shorthand for: > -x "buffer-export pdf" > so the -o switch comes too late to change the effect of -e. (Look at the > code for easyParse in LyX.cpp). The easy thing to do would be to add a > new switch, say, -E, which takes two arguments, and have that act as > shorthand for: > -x "buffer-export-as pdf /path/to/export.lyx" However, the above-proposed command line syntax seems more "natural" to me. How about something in the line of: @@ -1126,7 +1126,12 @@ int parse_execute(string const & arg, string const &, string & batch) return 1; } - +int parse_output_file(string const & filename, string const &, string & batch) +{ + /* set the output_file variable */ + return 1; +} + int parse_export(string const & type, string const &, string & batch) { if (type.empty()) { @@ -1134,7 +1139,12 @@ int parse_export(string const & type, string const &, string & batch) "--export switch")) << endl; exit(1); } - batch = "buffer-export " + type; + if (output_file != "") { + batch = "buffer-export-as " + type + output_file; + } + else { + batch = "buffer-export " + type; + } use_gui = false; return 1; } @@ -1211,6 +1221,8 @@ void LyX::easyParse(int & argc, char * argv[]) { map<string, cmd_helper> cmdmap; + cmdmap["-o"] = parse_output_file; + cmdmap["--output-file"] = parse_output_file; cmdmap["-dbg"] = parse_dbg; cmdmap["-help"] = parse_help; cmdmap["--help"] = parse_help; (Not complete, not tested) Günter