MCPcopy
hub / github.com/mislav/hub / getPassword

Function getPassword

github/config.go:194–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192}
193
194func getPassword() (string, error) {
195 stdin := int(syscall.Stdin)
196 initialTermState, err := terminal.GetState(stdin)
197 if err != nil {
198 return "", err
199 }
200
201 c := make(chan os.Signal)
202 signal.Notify(c, os.Interrupt, syscall.SIGTERM)
203 go func() {
204 s := <-c
205 terminal.Restore(stdin, initialTermState)
206 switch sig := s.(type) {
207 case syscall.Signal:
208 if int(sig) == 2 {
209 fmt.Println("^C")
210 }
211 }
212 os.Exit(1)
213 }()
214
215 passBytes, err := terminal.ReadPassword(stdin)
216 if err != nil {
217 return "", err
218 }
219
220 signal.Stop(c)
221 fmt.Print("\n")
222 return string(passBytes), nil
223}
224
225func (c *Config) Find(host string) *Host {
226 for _, h := range c.Hosts {

Callers 1

PromptForPasswordMethod · 0.85

Calls 2

PrintlnMethod · 0.65
PrintMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…