diff --git a/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java b/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java index 5e18b63..107fa1d 100644 --- a/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java +++ b/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java @@ -17,6 +17,11 @@ public class CommandLineController { public UserManager user = null; 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_list_accounts) this.list_accounts(); @@ -94,12 +99,13 @@ public class CommandLineController { private void show_help() { System.out.println("Valid options are:"); - System.out.println(" --help Shows this help."); - System.out.println(" --account Use account ."); - System.out.println(" --login Login to an existing telegram account."); - System.out.println(" --debug Show (lots of) debug information."); - System.out.println(" --list-accounts List all existing accounts "); - System.out.println(" --limit-messages Downloads at most the most recent messages."); + System.out.println(" -h, --help Shows this help."); + System.out.println(" -a, --account Use account ."); + System.out.println(" -l, --login Login to an existing telegram account."); + System.out.println(" --debug Show (lots of) debug information."); + System.out.println(" -A, --list-accounts List all existing accounts "); + System.out.println(" --limit-messages Downloads at most the most recent messages."); + System.out.println(" -t, --target Target directory for the files."); System.exit(0); } diff --git a/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java b/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java index dc2de3f..ca7cc97 100644 --- a/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java +++ b/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java @@ -8,6 +8,7 @@ class CommandLineOptions { public boolean cmd_debug = false; public boolean cmd_list_accounts = false; public Integer limit_messages = null; + public String target = null; public CommandLineOptions(String[] args) { String last_cmd = null; @@ -21,6 +22,9 @@ class CommandLineOptions { case "--limit-messages": this.limit_messages = Integer.parseInt(arg); break; + case "--target": + this.target = arg; + break; } last_cmd = null; continue; @@ -28,18 +32,22 @@ class CommandLineOptions { switch (arg) { case "--account": - last_cmd = arg; + case "-a": + last_cmd = "--account"; continue; case "--help": + case "-h": this.cmd_help = true; break; case "--login": + case "-l": this.cmd_login = true; break; case "--debug": this.cmd_debug = true; break; case "--list-accounts": + case "-A": this.cmd_list_accounts = true; break; case "--limit-messages": @@ -48,6 +56,10 @@ class CommandLineOptions { case "--console": this.cmd_console = true; break; + case "--target": + case "-t": + last_cmd = "--target"; + continue; default: throw new RuntimeException("Unknown command " + arg); } diff --git a/src/main/java/de/fabianonline/telegram_backup/Config.java b/src/main/java/de/fabianonline/telegram_backup/Config.java index 6e1b5c9..268fe1e 100644 --- a/src/main/java/de/fabianonline/telegram_backup/Config.java +++ b/src/main/java/de/fabianonline/telegram_backup/Config.java @@ -10,7 +10,7 @@ class Config { public static final String APP_APPVER = "0.1"; 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_DC = "dc.dat"; public static final String FILE_NAME_DB = "database.sqlite";