Files
esdi/cmd/repl.go
T
2025-10-29 22:57:21 +00:00

58 lines
1.0 KiB
Go

package cmd
import (
"esdi/peripheral"
"esdi/repl"
"github.com/spf13/cobra"
)
func replCmdAction(cmd *cobra.Command, args []string) {
r := repl.NewREPL(repl.REPLCfg{
PS1: "\rESDI > ",
})
perClerk := peripheral.NewPeripheralDeviceClerk()
discoverDevicesREPLCmd := repl.Command{
Name: "discover",
Usage: "discovers connected devices",
Action: func(r *repl.REPL, args []string) error {
err := perClerk.FindDevices()
if err != nil {
return err
}
return nil
},
}
listDevicesREPLCmd := repl.Command{
Name: "list",
Usage: "lists connected devices",
Action: func(r *repl.REPL, args []string) error {
_ = perClerk.ListDevices()
return nil
},
}
r.RegisterCMD(discoverDevicesREPLCmd)
r.RegisterCMD(listDevicesREPLCmd)
r.Start()
r.Close()
}
// removeLabelCmd represents the removeLabel command
var replCmd = &cobra.Command{
Use: "repl",
Short: "run the repl to interact with the display",
Long: ``,
Run: replCmdAction,
}
func init() {
rootCmd.AddCommand(replCmd)
}