34 lines
800 B
Haxe
34 lines
800 B
Haxe
package bin;
|
|
|
|
import kernel.peripherals.Peripherals.Peripheral;
|
|
import lib.CLIAppBase;
|
|
|
|
@:build(macros.Binstore.includeBin("Peripheral", ["ph", "peripheral"]))
|
|
class Peri extends CLIAppBase {
|
|
public function new() {
|
|
registerSyncSubcommand("inspect", (args) -> {
|
|
var addr = args.getString("addr");
|
|
var result = Peripheral.inspect(addr);
|
|
|
|
handle.writeLine("Types:");
|
|
for (type in result.types) {
|
|
handle.writeLine(" " + type);
|
|
}
|
|
|
|
handle.writeLine("Methods:");
|
|
for (method in result.methods) {
|
|
handle.writeLine(" " + method);
|
|
}
|
|
|
|
return true;
|
|
}, [Addr("addr")]);
|
|
|
|
registerSyncSubcommand("list", (args) -> {
|
|
for (addr in Peripheral.getAllAddresses()) {
|
|
handle.writeLine('$addr => ${Peripheral.getTypes(addr).join(", ")}');
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
}
|