mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-03-11 17:48:44 -05:00
fix(cli): make user deletion confirmation check Windows compatible (#2339)
The current implementation of the user confirmation when deleting a user using the CLI seems to favour Linux. On Windows the <ENTER> command adds "\r\n" to the user input while Linux only adds "\n". I have added an extra check to the confirmation, but GO is a new language for me, so there is probably a much better way to do this. --------- Co-authored-by: kolaente <k@knt.li>
This commit is contained in:
@@ -361,7 +361,11 @@ var userDeleteCmd = &cobra.Command{
|
||||
if err != nil {
|
||||
log.Fatalf("could not read confirmation message: %s", err)
|
||||
}
|
||||
if text != "YES, I CONFIRM\n" {
|
||||
|
||||
// On Windows <ENTER> a newline is \r\n, while on Linux it is only \n.
|
||||
text = strings.TrimRight(text, "\r\n")
|
||||
|
||||
if text != "YES, I CONFIRM" {
|
||||
log.Fatalf("invalid confirmation message")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user