Skip to content
brianmusePublic

About

Make crossword puzzles from the command line and publish them on swords.cx

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

PUZ

puz-cli

Make crossword puzzles from the command line. Publish them on swords.cx and get a link anyone can solve.

CI License: MIT OR Apache-2.0 Publish on swords.cx

Install · Try it · Commands · Full guide · swords.cx


macOS and Linux:

curl -fsSL https://swords.cx/install.sh | sh

Windows (PowerShell):

irm https://swords.cx/install.ps1 | iex
$ puz show hello-world.json
Hello, World (5x5)
S L A W #
H O N O R
A G G R O
H E L L O
# S O D S
   1A SLAW             Cabbage side at a cookout
   5A HONOR            Medal of ___
   8A HELLO            With 4-Down, a programmer's first words
   ...
  • One puzzle, one file. A puzzle is a plain JSON file. Every command reads or changes one file. No account, no server.
  • Fill a grid. puz autofill fills a grid with good words, and puz check says whether it can be filled. The word list downloads once, from its own site.
  • Every common format. Import Across Lite .puz. Export .puz, .jpz, a PNG, a printable PDF, or a newspaper submission PDF.
  • Publish in one command. puz publish puts a finished puzzle on swords.cx and prints a link to solve it in the browser, on any device.
  • Built for scripts and AI agents. Commands that report results take --json.

Install

macOS and Linux:

curl -fsSL https://swords.cx/install.sh | sh

This puts puz in ~/.local/bin and runs puz setup.

Windows (PowerShell):

irm https://swords.cx/install.ps1 | iex

This puts puz.exe in %LOCALAPPDATA%\Programs\puz, adds that folder to your PATH and runs puz setup.

There are builds for macOS (Apple silicon and Intel), Linux (x64 and arm64) and Windows (x64). puz tells you when a new version is out; puz update installs it. Anything else: build from source.

Try it

puz comes with a small puzzle. Publish it and open the link:

$ puz publish hello-world.puz
Saved hello-world.puz here: a small puzzle to try.
✓ Published Hello, World. Anyone with this link can solve it:
  https://swords.cx/p/…/

Commands

puz new "My Puzzle" --size 15x15        # write my-puzzle.json
puz block my-puzzle.json 4,0            # a black square and its symmetric partner
puz place my-puzzle.json 1a ALPS        # write an answer
puz clue my-puzzle.json 1a "Swiss peaks"
puz show my-puzzle.json                 # the grid and every clue
puz stats my-puzzle.json                # grid stats and a paper's rules
puz export my-puzzle.json --format pdf  # also puz, jpz, png, json
puz import puzzle.puz                   # a .puz to a puzzle file
puz publish my-puzzle.json              # put it on swords.cx and print the link
puz autofill my-puzzle.json --write     # fill the rest of the grid
puz check my-puzzle.json                # can the grid still be filled?
puz export my-puzzle.json --format nyt  # a NYT submission PDF
puz swords list                         # what you published, with solve stats

Run puz --help for every command. The full guide covers the fill commands, the word list, the file format, marks (rebus, circles, colors, walls), endings, stats, export and publishing.

Publishing on swords.cx

swords.cx is a free place to share crosswords: push a puzzle, get a link.

  • No account needed. Your computer keeps a key that owns each puzzle you publish.
  • Publish again to update. puz remembers the link in the puzzle file, so the link stays the same.
  • Your puzzles on any device. Run puz swords login EMAIL to add them to your account.
  • Manage them. Add a PIN, see solve stats, or take a puzzle down with puz swords.

You can also drop a .puz, .jpz or .ipuz file on the swords.cx home page.

Build from source

You need Rust 1.89 or newer.

git clone https://github.com/brianmuse/puz-cli
cd puz-cli
cargo build --release
./target/release/puz --help

Run the tests with cargo test --release.

This is one Cargo workspace with four packages:

Folder Package What it is
crates/puz puz-cli The puz command.
crates/puz-core puz-core A library: the puzzle file model and everything that works on one file.
crates/puz-fill puz-fill A library: the fill engine (checks, fill, autofill, black-square patterns). It also builds for WebAssembly.
crates/swords swords-client A library: publish to swords.cx and manage what you published.

vendor/ingrid_core is a copy of ingrid_core's fill search (MIT), with no word list in it. The fill commands download Spread the Wordlist by Brooke Husic and Enrique Henestroza Anguiano (CC BY-NC-SA 4.0) on first use; it is not part of this repo.

How to release

A tag starts the release. GitHub Actions (.github/workflows/release.yml) builds the five programs, writes SHA256SUMS, and makes the GitHub Release. swords.cx serves the newest release within 5 minutes, so the site needs no deploy.

  1. Set the new version in Cargo.toml ([workspace.package] version, and the matching puz-core and puz-fill versions in crates/puz/Cargo.toml). Run cargo build --release to update Cargo.lock.
  2. Commit: git commit -am "puz X.Y.Z".
  3. Tag: git tag vX.Y.Z. The tag must match the version, or the workflow stops.
  4. Push both: git push origin main vX.Y.Z.

License

Licensed under either of

at your option.

Unless you say otherwise, any contribution you submit for inclusion in this project, as defined in the Apache-2.0 license, is licensed as above, with no additional terms or conditions.

About

Make crossword puzzles from the command line and publish them on swords.cx

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages