1   /*
2    * BibSonomyExporter
3    * Copyright (C) 2007 Christian Schenk
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    * 
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18   */
19  package org.christianschenk.bibsonomy.export;
20  
21  import org.christianschenk.bibsonomy.export.delicious.DeliciousExportFormatWriter;
22  import org.christianschenk.bibsonomy.export.delicious.DeliciousImporter;
23  
24  public class Runner {
25  
26  	public static void main(final String[] args) {
27  		if (args.length == 0 || (args.length == 1 && "--help".equals(args[0]))) {
28  			System.out.println(getUsage());
29  			System.out.println("\nThis software uses the del.icio.us Java API Copyright (c) 2004-2007, David A. Czarnecki");
30  			System.exit(0);
31  		}
32  		if (args.length != 2 && args.length != 4) {
33  			System.out.println(getUsage());
34  			System.exit(1);
35  		}
36  
37  		switch (args.length) {
38  		case 2:
39  			new DeliciousExportFormatWriter(args[0], args[1]).doExport();
40  			break;
41  		case 4:
42  			new DeliciousImporter(args[0], args[1], args[2], args[3]).doImport();
43  			break;
44  		default:
45  			throw new RuntimeException("Something has gone wrong");
46  		}
47  	}
48  
49  	private static String getUsage() {
50  		return "Usage:\n" + "  import: [bibsonomy-username] [bibsonomy-api-key] [delicious-username] [delicious-password]\n" + "  export: [bibsonomy-username] [bibsonomy-api-key]\n" + "Example:\n" + "  export: java -jar <jar-file> <your-bibsonomy-username> <your-bibsonomy-apikey>";
51  	}
52  }