Mercurial > projects > mde
view util/mtcp.d @ 124:a2ef6b549101
Dynamic minimal size changing is now fully supported.
Support for reducing minimal size in layouts.
Editing numbers as text now always converts new number back to string at end of edit.
Floating point number display format changed.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 05 Jan 2009 12:43:27 +0000 |
parents | 108d123238c0 |
children |
line wrap: on
line source
/* LICENSE BLOCK Part of mde: a Modular D game-oriented Engine Copyright © 2007-2008 Diggory Hardy This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /************************************************************************************************** * A small program for reading and writing mergetag files. * * Note that it's limited to copying data types which DefaultData can handle due to the nature of * mergetag's extendability. *************************************************************************************************/ module ut.mtcp; import mde.mergetag.Reader; import mde.mergetag.Writer; import mde.mergetag.exception; import tango.io.Stdout; import tango.io.FilePath; // Logger, used by mergetag: import tango.util.log.Config; int main (char[][] args) { char[] inFile, outFile; bool badOpts = false; bool helpOnly = false; foreach (arg; args[1..$]) { if (arg == "-h" || arg == "--help") helpOnly = true; else { if (inFile is null) inFile = arg; else if (outFile is null) outFile = arg; else { badOpts = true; helpOnly = true; } } } if (outFile is null) helpOnly = badOpts = true; if (helpOnly) { if (badOpts) Stdout ("Error: bad options!").newline; Stdout ("Usage:").newline.opCall(args[0])(" [options] input_file output_file").newline; Stdout ("Options:").newline.opCall("-h\t--help\tPrint help message").newline; if (badOpts) return 1; else return 0; } IReader reader; try { reader = makeReader (FilePath(inFile), null, true); reader.read; } catch (MTException mte) { Stdout ("While reading "~inFile~":").newline; Stdout ("Mergetag exception:").newline.opCall(mte.msg).newline; return 2; } catch (Exception e) { Stdout ("While reading "~inFile~":").newline; Stdout ("Unhandled exception:").newline.opCall(e.msg).newline; return 2; } try { IWriter writer = makeWriter (outFile, reader.dataset, WriterMethod.FromExtension); writer.write; } catch (MTException mte) { Stdout ("While writing "~outFile~":").newline; Stdout ("Mergetag exception:").newline.opCall(mte.msg).newline; return 3; } catch (Exception e) { Stdout ("While writing "~outFile~":").newline; Stdout ("Unhandled exception:").newline.opCall(e.msg).newline; return 3; } Stdout ("Copy successful: "~inFile~" -> "~outFile).newline; return 0; }