(params *survey.QuestionOptions)
| 512 | } |
| 513 | |
| 514 | func (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 | |
| 540 | func WithNopCloser(writer io.Writer) io.WriteCloser { |
| 541 | return &NopCloser{writer} |
nothing calls this directly
no test coverage detected