(opts *ImportOptions)
| 148 | } |
| 149 | |
| 150 | func AskImportConfig(opts *ImportOptions) error { |
| 151 | // Validate file path |
| 152 | err := ask.AskInputQuestionWithSuggestion( |
| 153 | "file (path of the .json config file)", |
| 154 | &opts.FilePath, |
| 155 | opts.FilePath, |
| 156 | func(toComplete string) []string { |
| 157 | files, _ := filepath.Glob(toComplete + "*") |
| 158 | return files |
| 159 | }, |
| 160 | survey.WithValidator(survey.Required), |
| 161 | ) |
| 162 | if err != nil { |
| 163 | return err |
| 164 | } |
| 165 | config, err := readConfigFromFile(opts.IO.ColorScheme(), opts.FilePath) |
| 166 | if err != nil { |
| 167 | return err |
| 168 | } |
| 169 | opts.ImportConfig = *config |
| 170 | |
| 171 | scopeOptions := []string{} |
| 172 | if len(opts.ImportConfig.Rules) > 0 { |
| 173 | scopeOptions = append(scopeOptions, "rules") |
| 174 | } |
| 175 | if len(opts.ImportConfig.Synonyms) > 0 { |
| 176 | scopeOptions = append(scopeOptions, "synonyms") |
| 177 | } |
| 178 | if opts.ImportConfig.Settings != nil { |
| 179 | scopeOptions = append(scopeOptions, "settings") |
| 180 | } |
| 181 | |
| 182 | erroredScope := opts.Scope |
| 183 | opts.Scope = []string{} |
| 184 | err = ask.AskMultiSelectQuestion( |
| 185 | "scope (comma separated):", |
| 186 | erroredScope, |
| 187 | &opts.Scope, |
| 188 | scopeOptions, |
| 189 | survey.WithValidator(survey.Required), |
| 190 | ) |
| 191 | if err != nil { |
| 192 | return err |
| 193 | } |
| 194 | if utils.Contains(opts.Scope, "synonyms") { |
| 195 | err = ask.AskBooleanQuestion( |
| 196 | "Clear and replace existing synonyms? (default: no)", |
| 197 | &opts.ClearExistingSynonyms, |
| 198 | false, |
| 199 | ) |
| 200 | if err != nil { |
| 201 | return err |
| 202 | } |
| 203 | err = ask.AskBooleanQuestion( |
| 204 | "Forward synonyms to replicas? (default: no)", |
| 205 | &opts.ForwardSynonymsToReplicas, |
| 206 | false, |
| 207 | ) |
nothing calls this directly
no test coverage detected