Skip to content

Commit

Permalink
Deprecate conflicting echo overload (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt authored Sep 3, 2020
1 parent 3ed44d4 commit 68d12d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Deprecated
- Deprecated calling `echo` with `err` or `lineSeparator` but no `message`.


## 3.0.0
_2020-09-02_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -243,8 +244,17 @@ abstract class CliktCommand(
*/
open fun aliases(): Map<String, List<String>> = 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)
}

Expand Down

0 comments on commit 68d12d1

Please sign in to comment.