mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-12-25 22:35:35 +00:00
First tries.
This commit is contained in:
parent
9693371a3d
commit
166df82ac1
19
build.gradle
19
build.gradle
@ -10,6 +10,25 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.2.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.apiVersion = "1.0"
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compile('com.github.badoualy:kotlogram:666a81ef9d6707f117a3fecc2d21c91d51c7d075') {
|
||||
exclude module: 'slf4j-simple'
|
||||
|
@ -1,136 +0,0 @@
|
||||
/* Telegram_Backup
|
||||
* Copyright (C) 2016 Fabian Schlenz
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
package de.fabianonline.telegram_backup;
|
||||
|
||||
class CommandLineOptions {
|
||||
public static boolean cmd_console = false;
|
||||
public static boolean cmd_help = false;
|
||||
public static boolean cmd_login = false;
|
||||
public static boolean cmd_debug = false;
|
||||
public static boolean cmd_trace = false;
|
||||
public static boolean cmd_trace_telegram = false;
|
||||
public static boolean cmd_list_accounts = false;
|
||||
public static boolean cmd_version = false;
|
||||
public static boolean cmd_license = false;
|
||||
public static boolean cmd_daemon = false;
|
||||
public static boolean cmd_no_media = false;
|
||||
public static boolean cmd_anonymize = false;
|
||||
public static boolean cmd_stats = false;
|
||||
public static boolean cmd_channels = false;
|
||||
public static boolean cmd_supergroups = false;
|
||||
|
||||
public static String val_account = null;
|
||||
public static Integer val_limit_messages = null;
|
||||
public static String val_target = null;
|
||||
public static String val_export = null;
|
||||
public static Integer val_test = null;
|
||||
|
||||
public static void parseOptions(String[] args) {
|
||||
String last_cmd = null;
|
||||
|
||||
for (String arg : args) {
|
||||
if (last_cmd != null) {
|
||||
switch (last_cmd) {
|
||||
case "--account":
|
||||
val_account = arg; break;
|
||||
|
||||
case "--limit-messages":
|
||||
val_limit_messages = Integer.parseInt(arg); break;
|
||||
|
||||
case "--target":
|
||||
val_target = arg; break;
|
||||
|
||||
case "--export":
|
||||
val_export = arg; break;
|
||||
|
||||
case "--test":
|
||||
val_test = Integer.parseInt(arg); break;
|
||||
}
|
||||
last_cmd = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (arg) {
|
||||
case "-a": case "--account":
|
||||
last_cmd = "--account"; continue;
|
||||
|
||||
case "-h": case "--help":
|
||||
cmd_help = true; break;
|
||||
|
||||
case "-l": case "--login":
|
||||
cmd_login = true; break;
|
||||
|
||||
case "--debug":
|
||||
cmd_debug = true; break;
|
||||
|
||||
case "--trace":
|
||||
cmd_trace = true; break;
|
||||
|
||||
case "--trace-telegram":
|
||||
cmd_trace_telegram = true; break;
|
||||
|
||||
case "-A": case "--list-accounts":
|
||||
cmd_list_accounts = true; break;
|
||||
|
||||
case "--limit-messages":
|
||||
last_cmd = arg; continue;
|
||||
|
||||
case "--console":
|
||||
cmd_console = true; break;
|
||||
|
||||
case "-t": case "--target":
|
||||
last_cmd = "--target"; continue;
|
||||
|
||||
case "-V": case "--version":
|
||||
cmd_version = true; break;
|
||||
|
||||
case "-e": case "--export":
|
||||
last_cmd = "--export"; continue;
|
||||
|
||||
case "--license":
|
||||
cmd_license = true; break;
|
||||
|
||||
case "-d": case "--daemon":
|
||||
cmd_daemon = true; break;
|
||||
|
||||
case "--no-media":
|
||||
cmd_no_media = true; break;
|
||||
|
||||
case "--test":
|
||||
last_cmd = "--test"; continue;
|
||||
|
||||
case "--anonymize":
|
||||
cmd_anonymize = true; break;
|
||||
|
||||
case "--stats":
|
||||
cmd_stats = true; break;
|
||||
|
||||
case "--with-channels":
|
||||
cmd_channels = true; break;
|
||||
|
||||
case "--with-supergroups":
|
||||
cmd_supergroups = true; break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Unknown command " + arg);
|
||||
}
|
||||
}
|
||||
if (last_cmd != null) {
|
||||
CommandLineController.show_error("Command " + last_cmd + " had no parameter set.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/* Telegram_Backup
|
||||
* Copyright (C) 2016 Fabian Schlenz
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package de.fabianonline.telegram_backup
|
||||
internal object CommandLineOptions {
|
||||
public var cmd_console = false
|
||||
public var cmd_help = false
|
||||
public var cmd_login = false
|
||||
var cmd_debug = false
|
||||
var cmd_trace = false
|
||||
var cmd_trace_telegram = false
|
||||
var cmd_list_accounts = false
|
||||
var cmd_version = false
|
||||
var cmd_license = false
|
||||
var cmd_daemon = false
|
||||
var cmd_no_media = false
|
||||
var cmd_anonymize = false
|
||||
var cmd_stats = false
|
||||
var cmd_channels = false
|
||||
var cmd_supergroups = false
|
||||
var val_account:String? = null
|
||||
var val_limit_messages:Int? = null
|
||||
var val_target:String? = null
|
||||
var val_export:String? = null
|
||||
var val_test:Int? = null
|
||||
@JvmStatic fun parseOptions(args:Array<String>) {
|
||||
var last_cmd:String? = null
|
||||
loop@ for (arg in args)
|
||||
{
|
||||
if (last_cmd != null)
|
||||
{
|
||||
when (last_cmd) {
|
||||
"--account" -> val_account = arg
|
||||
"--limit-messages" -> val_limit_messages = Integer.parseInt(arg)
|
||||
"--target" -> val_target = arg
|
||||
"--export" -> val_export = arg
|
||||
"--test" -> val_test = Integer.parseInt(arg)
|
||||
}
|
||||
last_cmd = null
|
||||
continue
|
||||
}
|
||||
when (arg) {
|
||||
"-a", "--account" -> {
|
||||
last_cmd = "--account"
|
||||
continue@loop
|
||||
}
|
||||
"-h", "--help" -> cmd_help = true
|
||||
"-l", "--login" -> cmd_login = true
|
||||
"--debug" -> cmd_debug = true
|
||||
"--trace" -> cmd_trace = true
|
||||
"--trace-telegram" -> cmd_trace_telegram = true
|
||||
"-A", "--list-accounts" -> cmd_list_accounts = true
|
||||
"--limit-messages" -> {
|
||||
last_cmd = arg
|
||||
continue@loop
|
||||
}
|
||||
"--console" -> cmd_console = true
|
||||
"-t", "--target" -> {
|
||||
last_cmd = "--target"
|
||||
continue@loop
|
||||
}
|
||||
"-V", "--version" -> cmd_version = true
|
||||
"-e", "--export" -> {
|
||||
last_cmd = "--export"
|
||||
continue@loop
|
||||
}
|
||||
"--license" -> cmd_license = true
|
||||
"-d", "--daemon" -> cmd_daemon = true
|
||||
"--no-media" -> cmd_no_media = true
|
||||
"--test" -> {
|
||||
last_cmd = "--test"
|
||||
continue@loop
|
||||
}
|
||||
"--anonymize" -> cmd_anonymize = true
|
||||
"--stats" -> cmd_stats = true
|
||||
"--with-channels" -> cmd_channels = true
|
||||
"--with-supergroups" -> cmd_supergroups = true
|
||||
else -> throw RuntimeException("Unknown command " + arg)
|
||||
}
|
||||
}
|
||||
if (last_cmd != null)
|
||||
{
|
||||
CommandLineController.show_error("Command " + last_cmd + " had no parameter set.")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user