@@ -130,6 +130,26 @@ func readSecret(prompt string) (s []byte, err error) {
130130 return
131131}
132132
133+ // readPublic reads a value from the terminal. The prompt is ephemeral.
134+ func readPublic (prompt string ) (s []byte , err error ) {
135+ err = withTerminal (func (in , out * os.File ) error {
136+ fmt .Fprintf (out , "%s " , prompt )
137+ defer clearLine (out )
138+
139+ oldState , err := term .MakeRaw (int (in .Fd ()))
140+ if err != nil {
141+ return err
142+ }
143+ defer term .Restore (int (in .Fd ()), oldState )
144+
145+ t := term .NewTerminal (in , "" )
146+ line , err := t .ReadLine ()
147+ s = []byte (line )
148+ return err
149+ })
150+ return
151+ }
152+
133153// readCharacter reads a single character from the terminal with no echo. The
134154// prompt is ephemeral.
135155func readCharacter (prompt string ) (c byte , err error ) {
@@ -159,17 +179,25 @@ var pluginTerminalUI = &plugin.ClientUI{
159179 printf ("%s plugin: %s" , name , message )
160180 return nil
161181 },
162- RequestValue : func (name , message string , _ bool ) (s string , err error ) {
182+ RequestValue : func (name , message string , isSecret bool ) (s string , err error ) {
163183 defer func () {
164184 if err != nil {
165185 warningf ("could not read value for age-plugin-%s: %v" , name , err )
166186 }
167187 }()
168- secret , err := readSecret (message )
169- if err != nil {
170- return "" , err
188+ if isSecret {
189+ secret , err := readSecret (message )
190+ if err != nil {
191+ return "" , err
192+ }
193+ return string (secret ), nil
194+ } else {
195+ public , err := readPublic (message )
196+ if err != nil {
197+ return "" , err
198+ }
199+ return string (public ), nil
171200 }
172- return string (secret ), nil
173201 },
174202 Confirm : func (name , message , yes , no string ) (choseYes bool , err error ) {
175203 defer func () {
0 commit comments