services/device/device: make status command work for the device service
We already added support for the Status RPC for the device service
(https://vanadium-review.googlesource.com/#/c/11766/), so update the cmd-line
tool to support it.
Change-Id: Ibc8d8531756cf814afa58d095cdfd4692043a633
diff --git a/services/device/device/doc.go b/services/device/device/doc.go
index 57612c3..17eec24 100644
--- a/services/device/device/doc.go
+++ b/services/device/device/doc.go
@@ -25,7 +25,7 @@
kill Kill the given application instance.
revert Revert the device manager or application
update Update device manager or applications.
- status Get application status.
+ status Get device manager or application status.
debug Debug the device.
acl Tool for setting device manager Permissions
publish Publish the given application(s).
@@ -304,13 +304,13 @@
Device status
-Get the status of application installations and instances.
+Get the status of the device manager or application instances and installations.
Usage:
- device status <app name patterns...>
+ device status <name patterns...>
-<app name patterns...> are vanadium object names or glob name patterns
-corresponding to application installations and instances.
+<name patterns...> are vanadium object names or glob name patterns corresponding
+to the device manager service, or to application installations and instances.
Device debug
diff --git a/services/device/device/status.go b/services/device/device/status.go
index 13a505c..d32430e 100644
--- a/services/device/device/status.go
+++ b/services/device/device/status.go
@@ -16,11 +16,11 @@
var cmdStatus = &cmdline.Command{
Runner: globRunner(runStatus),
Name: "status",
- Short: "Get application status.",
- Long: "Get the status of application installations and instances.",
- ArgsName: "<app name patterns...>",
+ Short: "Get device manager or application status.",
+ Long: "Get the status of the device manager or application instances and installations.",
+ ArgsName: "<name patterns...>",
ArgsLong: `
-<app name patterns...> are vanadium object names or glob name patterns corresponding to application installations and instances.`,
+<name patterns...> are vanadium object names or glob name patterns corresponding to the device manager service, or to application installations and instances.`,
}
func runStatus(entry globResult, _ *context.T, stdout, _ io.Writer) error {
@@ -29,6 +29,8 @@
fmt.Fprintf(stdout, "Instance %v [State:%v,Version:%v]\n", entry.name, s.Value.State, s.Value.Version)
case device.StatusInstallation:
fmt.Fprintf(stdout, "Installation %v [State:%v,Version:%v]\n", entry.name, s.Value.State, s.Value.Version)
+ case device.StatusDevice:
+ fmt.Fprintf(stdout, "Device Service %v [State:%v,Version:%v]\n", entry.name, s.Value.State, s.Value.Version)
default:
return fmt.Errorf("Status returned unknown type: %T", s)
}
diff --git a/services/device/device/status_test.go b/services/device/device/status_test.go
index e4737ed..4284226 100644
--- a/services/device/device/status_test.go
+++ b/services/device/device/status_test.go
@@ -47,6 +47,10 @@
instanceUpdating,
fmt.Sprintf("Instance %v [State:Updating,Version:theatrical version]", appName),
},
+ {
+ deviceService,
+ fmt.Sprintf("Device Service %v [State:Running,Version:han shot first]", appName),
+ },
} {
var stdout, stderr bytes.Buffer
env := &cmdline.Env{Stdout: &stdout, Stderr: &stderr}
diff --git a/services/device/device/util_test.go b/services/device/device/util_test.go
index fae7c43..01bd228 100644
--- a/services/device/device/util_test.go
+++ b/services/device/device/util_test.go
@@ -43,6 +43,10 @@
State: device.InstanceStateNotRunning,
Version: "special edition",
}}
+ deviceService = device.StatusDevice{device.DeviceStatus{
+ State: device.InstanceStateRunning,
+ Version: "han shot first",
+ }}
)
func testHelper(t *testing.T, lower, upper string) {