-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.go
89 lines (79 loc) · 2.23 KB
/
command.go
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package devcon
type command string
//goland:noinspection SpellCheckingInspection
const (
// These commands represent queries, they don't make any changes to the
// system.
commandClasses command = "classes"
commandListClass command = "listclass"
commandDriverFiles command = "driverfiles"
commandDriverNodes command = "drivernodes"
commandHwIDs command = "hwids"
commandStack command = "stack"
commandStatus command = "status"
commandFind command = "find"
commandFindAll command = "findall"
// The commands represent actions, they _do_ make changes to the system.
commandClassFilter command = "classfilter"
commandDisable command = "disable"
commandDPAdd command = "dp_add"
commandDPDelete command = "dp_delete"
commandDPEnum command = "dp_enum"
commandEnable command = "enable"
commandInstall command = "install"
commandReboot command = "reboot"
commandRemove command = "remove"
commandRescan command = "rescan"
commandResources command = "resources"
commandRestart command = "restart"
commandSetHwID command = "sethwid"
commandUpdate command = "update"
commandUpdateNI command = "updateni"
)
// String returns the string representation of the command (used to pass to the
// run operation).
func (c command) String() string {
return string(c)
}
// CanReboot returns true if the associated command allows for conditional
// reboot.
//
//nolint:exhaustive // Any commands not specified are false.
func (c command) CanReboot() bool {
switch c {
case commandDisable:
case commandEnable:
case commandInstall:
case commandRemove:
case commandRescan:
case commandRestart:
case commandUpdate:
case commandUpdateNI:
return true
default:
return false
}
return false
}
// CanBeRemote returns true if the associated command can target a remote
// computer.
//
//nolint:exhaustive // Any commands not specified are false.
func (c command) CanBeRemote() bool {
switch c {
case commandClasses:
case commandFind:
case commandFindAll:
case commandHwIDs:
case commandListClass:
case commandRescan:
case commandResources:
case commandSetHwID:
case commandStack:
case commandStatus:
return true
default:
return false
}
return false
}