Collection of useful functions / commands that combine different functions from pgn-parser, pgn-reader, pgn-writer.
I have developed over years many different tools in the context of PGN, but combining them is not always easy. I don't want to have additional dependencies, so I want to have a collection of small functions that can be used in different projects.
So the pgn-tools will do the following:
- Provide Javascript/Typescript functions that can be used in any project.
- Provide a command line tool that can be used in any shell.
- Provide useful subcommands with different options per subcommand.
- Have an understandable API with good naming. Each part of functionality should go into different files, where each file includes sufficient information what to expect here.
To allow that, we have to define for which parts we use which words.
parse
: Read the game from a string/file, and return the parse tree as computed bypgn-parser
. No additional validation/checking/... is done here. This will be much faster than the other option. All exported functions ofpgn-parser
are exported without a change.read
: Parse the game as usual, but validate the moves by thepgn-reader
. You will get at the end a validated game, with additional information computed during that validation. It will of course more costly than only parsing. All input is read from files synchronously, because all tool functionality should be used in scripts (locally), and not in the browser.
The current implementation is very early, but I want to provide some overview of what was already achieved, and what will be next.
readFile
: Sufficiently well implemented, should be usable directly by other commands then.
To develop the files locally, you have to ensure to do the following before calling the files in directory bin
:
npm install
to have everything available.npm link
that creates local links to your declared bin files (seepackage.json
, therebin
what can be called).- Use the files then locally in the root of the repository:
npm-read -f game1.pgn
.