-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from synfinatic/fix-bell
fix bell/warning when selecting items during setup
- v2.0.0-beta4
- v2.0.0-beta3
- v2.0.0-beta2
- v2.0.0-beta1
- v1.17.0
- v1.16.1
- v1.16.0
- v1.15.1
- v1.15.0
- v1.14.3
- v1.14.2
- v1.14.1
- v1.14.0
- v1.13.1
- v1.13.0
- v1.12.0
- v1.11.0
- v1.10.0
- v1.9.10
- v1.9.9
- v1.9.8
- v1.9.7
- v1.9.6
- v1.9.5
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.1
- v1.8.0
- v1.7.5
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.1
- v1.6.0
- v1.5.1
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
/* | ||
* AWS SSO CLI | ||
* Copyright (c) 2021 Aaron Turner <synfinatic at gmail dot com> | ||
* | ||
* This program is free software: you can redistribute it | ||
* and/or modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or with the authors permission any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
/* | ||
* bellSkipper implements an io.WriteCloser that skips the terminal bell | ||
* character (ASCII code 7), and writes the rest to os.Stderr. It is used to | ||
* replace readline.Stdout, that is the package used by promptui to display the | ||
* prompts. | ||
* | ||
* This is a workaround for the bell issue documented in | ||
* https://github.com/manifoldco/promptui/issues/49#issuecomment-573814976 | ||
*/ | ||
type bellSkipper struct{} | ||
|
||
// Write implements an io.WriterCloser over os.Stderr, but it skips the terminal | ||
// bell character. | ||
func (bs *bellSkipper) Write(b []byte) (int, error) { | ||
const charBell = 7 // c.f. readline.CharBell | ||
if len(b) == 1 && b[0] == charBell { | ||
return 0, nil | ||
} | ||
return os.Stderr.Write(b) | ||
} | ||
|
||
// Close implements an io.WriterCloser over os.Stderr. | ||
func (bs *bellSkipper) Close() error { | ||
return os.Stderr.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters