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

Added a feature to display the version.

This commit is contained in:
Fabian Schlenz 2016-07-04 15:45:45 +02:00
parent e03f96363f
commit 523ee51d22
3 changed files with 35 additions and 28 deletions

View File

@ -17,13 +17,21 @@ public class CommandLineController {
public UserManager user = null; public UserManager user = null;
public CommandLineController(CommandLineOptions options) { public CommandLineController(CommandLineOptions options) {
if (options.cmd_version) {
System.out.println("Telegram_Backup v" + Config.APP_APPVER);
System.out.println("by Fabian Schlenz");
System.exit(0);
} else if (options.cmd_help) {
this.show_help();
}
if (options.target != null) { if (options.target != null) {
Config.FILE_BASE = options.target; Config.FILE_BASE = options.target;
} }
System.out.println("Target directory for files: " + Config.FILE_BASE); 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(); if (options.cmd_list_accounts) this.list_accounts();
app = new TelegramApp(Config.APP_ID, Config.APP_HASH, Config.APP_MODEL, Config.APP_SYSVER, Config.APP_APPVER, Config.APP_LANG); app = new TelegramApp(Config.APP_ID, Config.APP_HASH, Config.APP_MODEL, Config.APP_SYSVER, Config.APP_APPVER, Config.APP_LANG);

View File

@ -9,6 +9,7 @@ class CommandLineOptions {
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 String target = null;
public boolean cmd_version = false;
public CommandLineOptions(String[] args) { public CommandLineOptions(String[] args) {
String last_cmd = null; String last_cmd = null;
@ -31,35 +32,33 @@ class CommandLineOptions {
} }
switch (arg) { switch (arg) {
case "--account": case "-a": case "--account":
case "-a": last_cmd = "--account"; continue;
last_cmd = "--account";
continue; case "-h": case "--help":
case "--help": this.cmd_help = true; break;
case "-h":
this.cmd_help = true; case "-l": case "--login":
break; this.cmd_login = true; break;
case "--login":
case "-l":
this.cmd_login = true;
break;
case "--debug": case "--debug":
this.cmd_debug = true; this.cmd_debug = true; break;
break;
case "--list-accounts": case "-A": case "--list-accounts":
case "-A": this.cmd_list_accounts = true; break;
this.cmd_list_accounts = true;
break;
case "--limit-messages": case "--limit-messages":
last_cmd = arg; last_cmd = arg; continue;
continue;
case "--console": case "--console":
this.cmd_console = true; this.cmd_console = true; break;
break;
case "--target": case "-t": case "--target":
case "-t": last_cmd = "--target"; continue;
last_cmd = "--target";
continue; case "-V": case "--version":
this.cmd_version = true; continue;
default: default:
throw new RuntimeException("Unknown command " + arg); throw new RuntimeException("Unknown command " + arg);
} }

View File

@ -7,7 +7,7 @@ class Config {
public static final String APP_HASH = "16e4ff955cd0adfc058f95ca564f562d"; public static final String APP_HASH = "16e4ff955cd0adfc058f95ca564f562d";
public static final String APP_MODEL = "Desktop"; public static final String APP_MODEL = "Desktop";
public static final String APP_SYSVER = "1.0"; public static final String APP_SYSVER = "1.0";
public static final String APP_APPVER = "0.1"; public static final String APP_APPVER = "1.0";
public static final String APP_LANG = "en"; public static final String APP_LANG = "en";
public static String FILE_BASE = System.getProperty("user.home") + File.separatorChar + ".telegram_backup"; public static String FILE_BASE = System.getProperty("user.home") + File.separatorChar + ".telegram_backup";