MCPcopy Index your code
hub / github.com/devspace-sh/devspace / Question

Method Question

pkg/util/log/stream_logger.go:514–538  ·  view source on GitHub ↗
(params *survey.QuestionOptions)

Source from the content-addressed store, hash-verified

512}
513
514func (s *StreamLogger) Question(params *survey.QuestionOptions) (string, error) {
515 s.m.Lock()
516 defer s.m.Unlock()
517
518 if !s.isTerminal && !params.DefaultValueSet {
519 return "", fmt.Errorf("cannot ask question '%s' because currently you're not using devspace in a terminal and default value is also not provided", params.Question)
520 } else if !s.isTerminal && params.DefaultValueSet {
521 return params.DefaultValue, nil
522 }
523
524 // Check if we can ask the question
525 if s.level < logrus.InfoLevel {
526 return "", errors.Errorf("cannot ask question '%s' because log level is too low", params.Question)
527 }
528
529 // Try to silence the global log
530 id, err := AcquireGlobalSilence()
531 if err != nil {
532 return "", err
533 }
534 defer ReleaseGlobalSilence(id)
535
536 _, _ = s.write(logrus.InfoLevel, []byte("\n"))
537 return s.survey.Question(params)
538}
539
540func WithNopCloser(writer io.Writer) io.WriteCloser {
541 return &NopCloser{writer}

Callers

nothing calls this directly

Calls 7

writeMethod · 0.95
AcquireGlobalSilenceFunction · 0.85
ReleaseGlobalSilenceFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
QuestionMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected