From ab16c44de5f77a1f611fbbff255977ac9e39fc1f Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Mon, 29 Jan 2018 06:13:18 +0100 Subject: [PATCH] Added Any.toPrettyJson(). --- .../fabianonline/telegram_backup/CommandLineController.kt | 1 + src/main/kotlin/de/fabianonline/telegram_backup/Utils.kt | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt b/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt index 078ffc7..b539c0f 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt @@ -52,6 +52,7 @@ class CommandLineController { init { logger.info("CommandLineController started. App version {}", Config.APP_APPVER) + this.printHeader() if (CommandLineOptions.cmd_version) { System.exit(0) diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/Utils.kt b/src/main/kotlin/de/fabianonline/telegram_backup/Utils.kt index d7998c3..3b99292 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/Utils.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/Utils.kt @@ -182,7 +182,5 @@ fun String.anonymize(): String { return if (!CommandLineOptions.cmd_anonymize) this else this.replace(Regex("[0-9]"), "1").replace(Regex("[A-Z]"), "A").replace(Regex("[a-z]"), "a") + " (ANONYMIZED)" } -fun Any.toJson(): String { - - return Gson().toJson(this) -} +fun Any.toJson(): String = Gson().toJson(this) +fun Any.toPrettyJson(): String = GsonBuilder().setPrettyPrinting().create().toJson(this)