26 lines
751 B
JavaScript
26 lines
751 B
JavaScript
const fumen = require('tetris-fumen');
|
|
const { argv } = require('node:process');
|
|
const { fumenPageToInputState, fumenPagePlayMove, runFishCli } = require('./src/utils');
|
|
|
|
async function main() {
|
|
if (argv.length != 3) {
|
|
throw new Error('usage: node list <url>');
|
|
}
|
|
|
|
let url = argv[2];
|
|
let pages = fumen.decoder.decode(url);
|
|
if (pages.length !== 1) {
|
|
throw new Error('expected exactly one page');
|
|
}
|
|
|
|
let inputState = fumenPageToInputState(pages[0]);
|
|
let output = await runFishCli(['list'], inputState);
|
|
for (let move of output.moves) {
|
|
pages.push(fumenPagePlayMove(pages[0], move, { lock: false }));
|
|
}
|
|
|
|
console.log(fumen.encoder.encode(pages));
|
|
}
|
|
|
|
main().catch(e => console.error(e));
|