COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/ssmerge/ssmerge.cpp
Go to the documentation of this file.
00001 
00002 #include <stdio.h>
00003 #include <coopy/Options.h>
00004 #include <coopy/Diff.h>
00005 
00006 using namespace std;
00007 using namespace coopy::app;
00008 
00009 int main(int argc, char *argv[]) {
00010   Options opt("ssmerge");
00011   int r = opt.apply(argc,argv);
00012   if (r!=0) return r;
00013 
00014   bool help = opt.checkBool("help");
00015 
00016   const vector<string>& core = opt.getCore();
00017   if (core.size()>3) {
00018     fprintf(stderr, "Options not understood\n");
00019     return 1;
00020   }
00021 
00022   if (core.size()<3||help) {
00023     opt.beginHelp();
00024     opt.addUsage("ssmerge [options] FILE1 FILE2 FILE3");
00025     opt.addDescription("Merge table/database/spreadsheets. The first file must be a common ancestor of the remaining two.");
00026     opt.showOptions(OPTION_FOR_MERGE);
00027     opt.addExample("ssmerge numbers_buggy.csv numbers.csv numbers_buggy_add.csv",
00028                    "Merge two CSV tables (numbers.csv and numbers_buggy_add.csv) with a common ancestor (numbers_buggy.csv).").require("numbers_buggy.csv").require("numbers.csv").require("numbers_buggy_add.csv");
00029     opt.addExample("ssmerge --theirs numbers_buggy.csv numbers.csv numbers_conflict.csv",
00030                    "Merge numbers.csv and numbers_conflict.csv (with common ancestor numbers_buggy.csv), deferring to numbers_conflict.csv in the case of conflict.").require("numbers_buggy.csv").require("numbers.csv").require("numbers_conflict.csv");
00031     opt.addExample("ssmerge --ours numbers_buggy.csv numbers.csv numbers_conflict.csv",
00032                    "Merge numbers.csv and numbers_conflict.csv (with common ancestor numbers_buggy.csv), deferring to numbers.csv in the case of conflict.").require("numbers_buggy.csv").require("numbers.csv").require("numbers_conflict.csv");
00033     opt.addExample("ssmerge --inplace --theirs numbers_buggy.csv numbers.csv numbers_conflict.csv",
00034                    "Merge directly into numbers.csv.  Without --inplace, output goes to standard output.").require("numbers_buggy.csv").require("numbers.csv").require("numbers_conflict.csv");
00035     opt.endHelp();
00036     return help?0:1;
00037   }
00038 
00039   Diff diff;
00040   return diff.apply(opt);
00041 }
00042 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines