github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/internal/backend/api.go (about) 1 package backend 2 3 import ( 4 "github.com/criteo/command-launcher/internal/command" 5 "github.com/criteo/command-launcher/internal/repository" 6 ) 7 8 var RESERVED_CMD_SEARCH_KEY map[string]bool = map[string]bool{ 9 "#login": true, 10 "#package": true, 11 "#remote": true, 12 "#update": true, 13 "#rename": true, 14 "#config": true, 15 "#version": true, 16 "#help": true, 17 "#completion": true, 18 } 19 20 type Backend interface { 21 // Load all managed repositories 22 Reload() error 23 // Find a command with its group name and command name. 24 // For the root level executable command, the group is empty string. 25 // For the group command, the name is empty 26 // 27 // The group and cmd could be an alias defined by the RenameCommand 28 // function. In this case, the FindCommand function is able to return 29 // the original command 30 // It maps the (group, name) to (registry/repository, package, group, name) 31 FindCommand(group string, name string) (command.Command, error) 32 33 FindCommandByFullName(fullName string) (command.Command, error) 34 35 // Get all group commands 36 GroupCommands() []command.Command 37 38 // Get all executable commands 39 ExecutableCommands() []command.Command 40 41 // Get system command by name 42 SystemCommand(name string) command.Command 43 44 // Rename a command with a new name 45 RenameCommand(cmd command.Command, new_name string) error 46 47 // Get all renamed commands 48 AllRenamedCommands() map[string]string 49 50 // Find a system command by its name 51 FindSystemCommand(name string) (command.Command, error) 52 53 // Get all packages sources managed by this backend 54 AllPackageSources() []*PackageSource 55 56 // Return all repositories or an empty slice 57 AllRepositories() []repository.PackageRepository 58 59 // Return default local repository 60 DefaultRepository() repository.PackageRepository 61 62 // Return dropin local repsository 63 DropinRepository() repository.PackageRepository 64 65 // Print out the command resolution details 66 Debug() 67 }