From 68d12d19a65a13ecdc6db345427378b9aca90bea Mon Sep 17 00:00:00 2001 From: AJ Alt Date: Thu, 3 Sep 2020 14:54:40 -0700 Subject: [PATCH] Deprecate conflicting echo overload (#234) --- CHANGELOG.md | 4 ++++ .../com/github/ajalt/clikt/core/CliktCommand.kt | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd02575ae..3f2b8411f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Deprecated +- Deprecated calling `echo` with `err` or `lineSeparator` but no `message`. + + ## 3.0.0 _2020-09-02_ diff --git a/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt b/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt index 9c28d21d2..cc369c611 100644 --- a/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt +++ b/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt @@ -3,6 +3,7 @@ package com.github.ajalt.clikt.core import com.github.ajalt.clikt.completion.CompletionGenerator import com.github.ajalt.clikt.mpp.exitProcessMpp import com.github.ajalt.clikt.mpp.readEnvvar +import com.github.ajalt.clikt.output.CliktConsole import com.github.ajalt.clikt.output.HelpFormatter.ParameterHelp import com.github.ajalt.clikt.output.TermUi import com.github.ajalt.clikt.parameters.arguments.Argument @@ -243,8 +244,17 @@ abstract class CliktCommand( */ open fun aliases(): Map> = emptyMap() - /** Prints [lineSeparator] to `stdout`, or to `stderr` if [err] is true */ - protected fun echo(err: Boolean = false, lineSeparator: String = currentContext.console.lineSeparator) { + /** Print the default [line separator][CliktConsole.lineSeparator] to `stdout` */ + protected fun echo() { + echo("") + } + + @Deprecated( + message="Specify message explicitly with `err` or `lineSeparator`", + replaceWith = ReplaceWith("echo(\"\", err=err, lineSeparator=lineSeparator)") + ) + /** @suppress */ + protected fun echo(err: Boolean, lineSeparator: String ) { echo("", err = err, lineSeparator = lineSeparator) }