-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathping_cmd.go
More file actions
52 lines (45 loc) · 1.6 KB
/
ping_cmd.go
File metadata and controls
52 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package system
import (
"github.com/jfrog/jfrog-cli-application/application/app"
"github.com/jfrog/jfrog-cli-application/application/commands"
"github.com/jfrog/jfrog-cli-application/application/commands/utils"
"github.com/jfrog/jfrog-cli-application/application/common"
"github.com/jfrog/jfrog-cli-application/application/service"
commonCLiCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
)
type pingCommand struct {
systemService service.SystemService
serverDetails *coreConfig.ServerDetails
}
func (pc *pingCommand) Run() error {
ctx := &service.Context{ServerDetails: pc.serverDetails}
return pc.systemService.Ping(ctx)
}
func (pc *pingCommand) ServerDetails() (*coreConfig.ServerDetails, error) {
return pc.serverDetails, nil
}
func (pc *pingCommand) CommandName() string {
return commands.Ping
}
func (pc *pingCommand) prepareAndRunCommand(ctx *components.Context) error {
serverDetails, err := utils.ServerDetailsByFlags(ctx)
if err != nil {
return err
}
pc.serverDetails = serverDetails
return commonCLiCommands.Exec(pc)
}
func GetPingCommand(appContext app.Context) components.Command {
cmd := &pingCommand{systemService: appContext.GetSystemService()}
return components.Command{
Name: commands.Ping,
Description: "Ping the application server",
Category: common.CategorySystem,
Aliases: []string{"p"},
Arguments: []components.Argument{},
Flags: commands.GetCommandFlags(commands.Ping),
Action: cmd.prepareAndRunCommand,
}
}