use names

use validate

pub fn main(world: World) -> Void raises [NotFound, TooLarge, Io] {
    let fs: Fs = std.fs.host()
    var path_storage: [64]u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    let path: String = check std.path.join(path_storage, ".zero", inputName())
    let created: Maybe<owned<File>> = std.fs.create(fs, path)
    if created.has {
        var file: owned<File> = created.value
        if !std.fs.writeAll(&mut file, std.mem.span("batch3 cli ok\n")) {
            return
        }
    }
    var read_storage: [64]u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    var alloc: FixedBufAlloc = std.mem.fixedBufAlloc(read_storage)
    var body: owned<ByteBuf> = check std.fs.readAllOrRaise(alloc, fs, path, 64)
    if isExpected(std.mem.bufBytes(&body)) {
        check world.out.write("batch3 cli ok\n")
    }
}
