COOPY » Guide
version 0.6.5
|
00001 00002 #include <stdio.h> 00003 #include <coopy/Diff.h> 00004 00005 using namespace coopy::app; 00006 using namespace std; 00007 00008 int main(int argc, char *argv[]) { 00009 Options opt("ssdiff"); 00010 int r = opt.apply(argc,argv); 00011 if (r!=0) return r; 00012 00013 bool help = opt.checkBool("help"); 00014 00015 const vector<string>& core = opt.getCore(); 00016 if (opt.checkBool("git")) { 00017 if (core.size()!=7) { 00018 fprintf(stderr, "Expected 7 parameters from git, but got %d\n", 00019 core.size()); 00020 return 1; 00021 } 00022 00023 string path = core[0]; 00024 string old_file = core[1]; 00025 string old_hex = core[2]; 00026 string old_mode = core[3]; 00027 string new_file = core[4]; 00028 string new_hex = core[5]; 00029 string new_mode = core[6]; 00030 vector<string>& coreMod = opt.getCoreMod(); 00031 coreMod.clear(); 00032 coreMod.push_back(old_file); 00033 coreMod.push_back(new_file); 00034 printf("--- a/%s\n", path.c_str()); 00035 printf("+++ b/%s\n", path.c_str()); 00036 } 00037 if (core.size()>2) { 00038 fprintf(stderr, "Options not understood\n"); 00039 return 1; 00040 } 00041 00042 if ((core.size()<1&&opt.checkString("patch")=="")||help) { 00043 opt.beginHelp(); 00044 opt.addUsage("ssdiff [options] FILE1 FILE2"); 00045 opt.addDescription("Show the difference between two tables/databases/spreadsheets."); 00046 opt.showOptions(OPTION_FOR_DIFF); 00047 opt.addExample("ssdiff numbers_buggy.csv numbers.csv", 00048 "Compare two tables. Output goes to standard output.").require("numbers_buggy.csv").require("numbers.csv"); 00049 opt.addExample("ssdiff --unordered numbers_buggy.csv numbers.csv", 00050 "Compare two tables, neglecting row order.").require("numbers_buggy.csv").require("numbers.csv"); 00051 opt.addExample("ssdiff --format sql numbers_buggy.sqlite numbers.sqlite", 00052 "Compare two databases, with output in SQL format.").require("numbers_buggy.sqlite").require("numbers.sqlite"); 00053 opt.addExample("ssdiff --format hilite --output review.csv numbers_buggy.csv numbers.csv","Generate tabular diff for eyeballing. If ssdiff is compiled with gnumeric support, and output format is *.xls, color highlighting is added.").require("numbers_buggy.csv").require("numbers_buggy.csv").require("numbers.csv"); 00054 opt.endHelp(); 00055 00056 return help?0:1; 00057 } 00058 00059 Diff diff; 00060 return diff.apply(opt); 00061 } 00062