1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-23 01:06:17 +00:00

Files get saved to the user dir by default, but you can change this value by using '--target'.

This commit is contained in:
Fabian Schlenz 2016-07-04 15:37:23 +02:00
parent 07ba594a15
commit e03f96363f
3 changed files with 26 additions and 8 deletions

View File

@ -17,6 +17,11 @@ public class CommandLineController {
public UserManager user = null; public UserManager user = null;
public CommandLineController(CommandLineOptions options) { public CommandLineController(CommandLineOptions options) {
if (options.target != null) {
Config.FILE_BASE = options.target;
}
System.out.println("Target directory for files: " + Config.FILE_BASE);
if (options.cmd_help) this.show_help(); if (options.cmd_help) this.show_help();
if (options.cmd_list_accounts) this.list_accounts(); if (options.cmd_list_accounts) this.list_accounts();
@ -94,12 +99,13 @@ public class CommandLineController {
private void show_help() { private void show_help() {
System.out.println("Valid options are:"); System.out.println("Valid options are:");
System.out.println(" --help Shows this help."); System.out.println(" -h, --help Shows this help.");
System.out.println(" --account <x> Use account <x>."); System.out.println(" -a, --account <x> Use account <x>.");
System.out.println(" --login Login to an existing telegram account."); System.out.println(" -l, --login Login to an existing telegram account.");
System.out.println(" --debug Show (lots of) debug information."); System.out.println(" --debug Show (lots of) debug information.");
System.out.println(" --list-accounts List all existing accounts "); System.out.println(" -A, --list-accounts List all existing accounts ");
System.out.println(" --limit-messages <x> Downloads at most the most recent <x> messages."); System.out.println(" --limit-messages <x> Downloads at most the most recent <x> messages.");
System.out.println(" -t, --target <x> Target directory for the files.");
System.exit(0); System.exit(0);
} }

View File

@ -8,6 +8,7 @@ class CommandLineOptions {
public boolean cmd_debug = false; public boolean cmd_debug = false;
public boolean cmd_list_accounts = false; public boolean cmd_list_accounts = false;
public Integer limit_messages = null; public Integer limit_messages = null;
public String target = null;
public CommandLineOptions(String[] args) { public CommandLineOptions(String[] args) {
String last_cmd = null; String last_cmd = null;
@ -21,6 +22,9 @@ class CommandLineOptions {
case "--limit-messages": case "--limit-messages":
this.limit_messages = Integer.parseInt(arg); this.limit_messages = Integer.parseInt(arg);
break; break;
case "--target":
this.target = arg;
break;
} }
last_cmd = null; last_cmd = null;
continue; continue;
@ -28,18 +32,22 @@ class CommandLineOptions {
switch (arg) { switch (arg) {
case "--account": case "--account":
last_cmd = arg; case "-a":
last_cmd = "--account";
continue; continue;
case "--help": case "--help":
case "-h":
this.cmd_help = true; this.cmd_help = true;
break; break;
case "--login": case "--login":
case "-l":
this.cmd_login = true; this.cmd_login = true;
break; break;
case "--debug": case "--debug":
this.cmd_debug = true; this.cmd_debug = true;
break; break;
case "--list-accounts": case "--list-accounts":
case "-A":
this.cmd_list_accounts = true; this.cmd_list_accounts = true;
break; break;
case "--limit-messages": case "--limit-messages":
@ -48,6 +56,10 @@ class CommandLineOptions {
case "--console": case "--console":
this.cmd_console = true; this.cmd_console = true;
break; break;
case "--target":
case "-t":
last_cmd = "--target";
continue;
default: default:
throw new RuntimeException("Unknown command " + arg); throw new RuntimeException("Unknown command " + arg);
} }

View File

@ -10,7 +10,7 @@ class Config {
public static final String APP_APPVER = "0.1"; public static final String APP_APPVER = "0.1";
public static final String APP_LANG = "en"; public static final String APP_LANG = "en";
public static final String FILE_BASE = "data"; public static String FILE_BASE = System.getProperty("user.home") + File.separatorChar + ".telegram_backup";
public static final String FILE_NAME_AUTH_KEY = "auth.dat"; public static final String FILE_NAME_AUTH_KEY = "auth.dat";
public static final String FILE_NAME_DC = "dc.dat"; public static final String FILE_NAME_DC = "dc.dat";
public static final String FILE_NAME_DB = "database.sqlite"; public static final String FILE_NAME_DB = "database.sqlite";