github.com/devcamcar/cli@v0.0.0-20181107134215-706a05759d18/commands/commands.go (about) 1 package commands 2 3 import ( 4 "sort" 5 6 "github.com/fnproject/cli/common" 7 "github.com/fnproject/cli/objects/app" 8 "github.com/fnproject/cli/objects/call" 9 "github.com/fnproject/cli/objects/context" 10 "github.com/fnproject/cli/objects/fn" 11 "github.com/fnproject/cli/objects/log" 12 "github.com/fnproject/cli/objects/server" 13 "github.com/fnproject/cli/objects/trigger" 14 "github.com/urfave/cli" 15 ) 16 17 type cmd map[string]cli.Command 18 19 // Commands map of all top-level commands 20 var Commands = cmd{ 21 "build": BuildCommand(), 22 "build-server": BuildServerCommand(), 23 "bump": common.BumpCommand(), 24 "call": CallCommand(), 25 "invoke": InvokeCommand(), 26 "configure": ConfigureCommand(), 27 "create": CreateCommand(), 28 "delete": DeleteCommand(), 29 "deploy": DeployCommand(), 30 "get": GetCommand(), 31 "init": InitCommand(), 32 "inspect": InspectCommand(), 33 "list": ListCommand(), 34 "migrate": MigrateCommand(), 35 "push": PushCommand(), 36 "start": StartCommand(), 37 "stop": StopCommand(), 38 "unset": UnsetCommand(), 39 "update": UpdateCommand(), 40 "use": UseCommand(), 41 } 42 43 var CreateCmds = cmd{ 44 "apps": app.Create(), 45 "functions": fn.Create(), 46 "triggers": trigger.Create(), 47 "context": context.Create(), 48 } 49 50 var ConfigCmds = cmd{ 51 "apps": app.SetConfig(), 52 "functions": fn.SetConfig(), 53 } 54 55 var ConfigListCmds = cmd{ 56 "apps": app.ListConfig(), 57 "functions": fn.ListConfig(), 58 } 59 60 var ConfigGetCmds = cmd{ 61 "apps": app.GetConfig(), 62 "functions": fn.GetConfig(), 63 } 64 65 var ConfigSetCmds = cmd{ 66 "apps": app.SetConfig(), 67 "functions": fn.SetConfig(), 68 } 69 70 var ConfigUnsetCmds = cmd{ 71 "apps": app.UnsetConfig(), 72 "functions": fn.UnsetConfig(), 73 } 74 75 var DeleteCmds = cmd{ 76 "apps": app.Delete(), 77 "functions": fn.Delete(), 78 "context": context.Delete(), 79 "triggers": trigger.Delete(), 80 } 81 82 var GetCmds = cmd{ 83 "config": ConfigCommand("get"), 84 "logs": log.Get(), 85 "calls": call.Get(), 86 } 87 88 var InspectCmds = cmd{ 89 "apps": app.Inspect(), 90 "context": context.Inspect(), 91 "functions": fn.Inspect(), 92 "triggers": trigger.Inspect(), 93 } 94 95 var ListCmds = cmd{ 96 "config": ConfigCommand("list"), 97 "apps": app.List(), 98 "functions": fn.List(), 99 "triggers": trigger.List(), 100 "calls": call.List(), 101 "contexts": context.List(), 102 } 103 104 var UnsetCmds = cmd{ 105 "config": ConfigCommand("unset"), 106 "context": context.Unset(), 107 } 108 109 var UpdateCmds = cmd{ 110 "apps": app.Update(), 111 "functions": fn.Update(), 112 "context": context.Update(), 113 "server": server.Update(), 114 "trigger": trigger.Update(), 115 } 116 117 var UseCmds = cmd{ 118 "context": context.Use(), 119 } 120 121 // GetCommands returns a list of cli.commands 122 func GetCommands(commands map[string]cli.Command) []cli.Command { 123 cmds := []cli.Command{} 124 for _, cmd := range commands { 125 cmds = append(cmds, cmd) 126 } 127 128 sort.Sort(cli.CommandsByName(cmds)) 129 return cmds 130 }