Skip to content

Commit

Permalink
Default to exit code 0 for PrintMessage (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt authored Jul 10, 2023
1 parent 9eb6683 commit b0a12bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Changed
- Updated Kotlin to 1.9.0
- `PrintMessage` and `PrintCompletionMessage` now default to exiting with a status code 0, which is the behavior they had in 3.x. ([#419](https://github.com/ajalt/clikt/issues/419))

## 4.0.0
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,18 @@ class PrintHelpMessage(
* Execution should be immediately halted.
*/
open class PrintMessage(
/** The message to print */
message: String,
statusCode: Int = 1,
/**
* The value to use as the exit code for the process.
*
* If you use [CliktCommand.main], it will pass this value to `exitProcess` after printing
* [message]. Defaults to 0.
*/
statusCode: Int = 0,
/**
* If true, the error message should be printed to stderr.
*/
printError: Boolean = false,
) : CliktError(message, statusCode = statusCode, printError = printError)

Expand All @@ -76,7 +86,7 @@ class Abort : ProgramResult(statusCode = 1)
*
* Execution should be immediately halted without an error.
*/
class PrintCompletionMessage(message: String) : PrintMessage(message)
class PrintCompletionMessage(message: String) : PrintMessage(message, statusCode = 0)

/** An exception that signals a user error. */
open class UsageError(
Expand Down

0 comments on commit b0a12bc

Please sign in to comment.