Skip to content

[Compiler] Thoughts about a custom interface for inklecate #933

@ephread

Description

@ephread

Since we are soon going to have a functional compiler in the main branch (yay \o/ 🎉) with its own inklecate (double yay \o/ 🎉), I want to bring up something that has been on my mind for a while.

The original inklecate:

  1. has a pretty barebone interface;
  2. lacks a command that makes it easy to identify from external tools – such as a "version" option that returns a successful exit status.

The reasons behind 1. are easy to infer; inklecate contains zero dependencies, which makes argument parsing difficult and inkle probably never needed to support long arguments. As for 2., there's an opened issue on the main repo, but it hasn't seen much activity.

I think we have an opportunity to make some improvements (IMHO – this is, of course, relative) and, in full honesty, solve some of my pain points. 😅 I've thought about discussing the topic and creating a PR for upstream in the past, but I realised pretty quickly it would end up increasing the maintenance burden for inkle.

Here's what I have in mind:

  1. I'd like to split each of inklecate's main features into separate subcommands with separate sets of options (expressed both through short and long flags), see below.

  2. Since the interface is going to be different, I'd like to use a different command name to prevent confusion. (The name is pending, but I've used inklenode below.)

Both the runtime and the compiler would remain free of external dependencies, but inklenode would have a tiny depency on a good argument parsing library. I can live with that given it's not meant to be embedded in a webpage.

Command Interface

Main

Usage: inklenode <command> [<args>]

The inklenode commands are:
   build           Build the given story
   play            Play the given story
   stats           Print statistics about the given story
   lsp             Start the language server

Options:
   -V, --version   Print the version
   -h, --help      Print the quick help

See `inklenode help <command>' for information on a specific command.
For the full documentation, see: https://github.com/y-lohse/inkjs

Build

Usage: inklenode build [-cvj] [-o <filename>] <file>

Compile the given ink story into the JSON intermediate representation.

Options:
   -o, --output=<filename>    Output file name
   -c, --count-visits         Count all visits to knots, stitches and weave points, not
                              just those referenced by TURNS_SINCE and read counts
   -j, --json                 Print errors and warnings in JSON (for communication with tools like Inky)
   -v, --verbose              Verbose mode; print compilation timings
   -h, --help                 Print this message

Play

Usage: inklenode play [-jk] <file>

Play the given ink story. <file> can either be a valid JSON file or an ink file.

Options:
   -j, --json                 Output playthrough in JSON (for communication with tools like Inky)
   -k, --keep-running         Keep inklenode running in play mode even after the story is complete
   -h, --help                 Print this message

Stats

Usage: inklenode stats [-j] <file>

Print statistics about the given story, including word count. <file> can either
be a valid JSON file or an ink file.

Options:
   -j, --json                 Output the statistics in JSON (for communication with tools like Inky)
   -h, --help                 Print this message

Language Server Protocol (Future)

Usage: inklenode lsp [--node-ipc|--stdio|--socket=<number>]

Starts the language server.

Options:
   --node-ipc                 Use node's IPC to communicate with the language client
   --stdio                    Use standard I/O to communicate with the language client
   --socket=<number>          Use the given socket number to communicate with the language client
   -h, --help                 Print this message

Version

$ inklenode --version
inklenode 2.1.0
Compatible with: inklecate 1.0.0

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions