
import 'package:oto/oto/application.dart';
import 'package:oto/oto/commands/command.dart';
import 'package:oto/oto/data/command_data.dart';

class PrintCommand extends Command {
  Function? get error => null;

  @override
  Future execute(DataCommand command) async {
    var data = DataPrint.fromJson(getParam(command));
    // await CLI.println(data.message, color: Color.red);
    Application.log(data.message);

    return complete(0, command);
  }
}

void registerPrintCommand() {
  Command.register(
    CommandType.Print,
    () => PrintCommand(),
    spec: const CommandSpec(
      type: CommandType.Print,
      category: 'util',
      dataModel: 'DataPrint',
      samplePath: 'assets/yaml/sample/01_basic.yaml',
    ),
  );
}
