| 249 | } |
| 250 | |
| 251 | func (i *installCmd) completion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 252 | var suggestions []string |
| 253 | |
| 254 | if fileio.PathExists(dirs.PortsDir) { |
| 255 | i.buildSuggestions(&suggestions, dirs.PortsDir, toComplete) |
| 256 | } |
| 257 | |
| 258 | projectPortsDir := filepath.Join(dirs.ConfProjectsDir, i.celer.Project().GetName()) |
| 259 | if fileio.PathExists(projectPortsDir) { |
| 260 | i.buildSuggestions(&suggestions, projectPortsDir, toComplete) |
| 261 | } |
| 262 | |
| 263 | // Support flags completion. |
| 264 | commands := []string{ |
| 265 | "--dev", "-d", |
| 266 | "--force", "-f", |
| 267 | "--recursive", "-r", |
| 268 | "--jobs", "-j", |
| 269 | "--verbose", "-v", |
| 270 | } |
| 271 | |
| 272 | for _, flag := range commands { |
| 273 | if strings.HasPrefix(flag, toComplete) { |
| 274 | suggestions = append(suggestions, flag) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | return suggestions, cobra.ShellCompDirectiveNoFileComp |
| 279 | } |