A powerful CLI tool with handy commands for Odyc.js developers. Generate code from sprites and perform various development tasks to make your life with Odyc.js easier.
- Sprite Code Generation: Convert PNG sprite images into JavaScript configuration files
- Color Palette Analysis: Automatically extract and optimize color palettes from sprites
- Multi-sprite Support: Process multiple PNG files in a single command
- Smart Color Indexing: Efficient color mapping with support for up to 62 unique colors
- Flexible Output: Generate JavaScript configuration files with customizable paths
- Account Authentication: Sign in securely from the terminal using the OAuth 2.1 device flow
- Game Scaffolding: Create a new Odyc game from a starter template with a single command
- One-command Deploy: Publish your game to Odyc and get a shareable, playable URL
- Developer-friendly: Beautiful terminal output with colored logging and progress indicators
- Go 1.24 or higher
- PNG sprite images (for sprite generation)
go install github.com/meldiron/odyc-cli@latest# Show help
odyc-cli
odyc-cli --helpGenerate JavaScript configuration from sprite PNG files.
odyc-cli sprites [OPTIONS]Options:
-a, --assets <path>- Path to assets directory containing PNG files (required)-o, --output <path>- Path to output JavaScript file (required)-f, --force- Overwrite output file if it exists-h, --help- Show help for sprites command
Example:
odyc-cli sprites --assets ./game-sprites --output ./src/gameConfig.js --forceGenerated Output:
var gameConfig = {
cellWidth: 6,
cellHeight: 5,
colors: [
"#ff0000ff",
"#00ff00ff",
"#0000ffff"
],
sprites: {
"player": `
..12..
.1221.
122221
.1221.
..12..
`,
"enemy": `
..13..
.1331.
133331
.1331.
..13..
`
}
};Create a new game on your Odyc account and scaffold a local folder for it. Prompts for a folder name (or accepts one as an argument), creates the game via the API (using the games.create scope), then scaffolds a starter project and an odyc.json linking the folder to the game. Requires you to be signed in (odyc-cli login).
The scaffold is a small, modular game you can play immediately by opening index.html (it loads Odyc.js from a CDN) and grow from there:
my-game/
βββ index.html # Loads Odyc + every game file, in order. Open this to play.
βββ index.js # Entry point β starts the first scene.
βββ scenes/ # One file per scene (a screen / state of the game).
β βββ title.js
β βββ world.js
βββ utils/ # Shared, reusable code (palette, sprites, helpers).
β βββ sprites.js
βββ odyc.json # Links this folder to your game on Odyc.
There is no build step: every .js file is loaded into one shared scope, so anything defined in one file is available in the others.
As long as you're signed in (odyc-cli login), you can deploy the new game right away β sign-in authorizes deploys for all of your games.
odyc-cli create [folder]Example:
odyc-cli create my-game
cd my-game
open index.html # play locally
# edit scenes/, utils/ and index.js
odyc-cli deployOptions:
-h, --help- Show help for create command
Bundle the current folder's game code into a single file and update the linked game with it. Files are concatenated in the same order index.html loads them β every *.js in utils/, then every *.js in scenes/, then index.js last β so the deployed bundle behaves exactly like the game does locally. (Legacy single-file projects with just a game.js are still deployed as-is.) The game must already exist (odyc-cli create) and be recorded in odyc.json; this command only updates code, it does not create games. When finished, the CLI prints the playable URL.
Code updates are authorized via an OAuth 2.1 Rich Authorization Request (type: game, actions: [code.write], identifier: *) granted at sign-in β run odyc-cli login first. The wildcard identifier authorizes deploys for all of your games in a single sign-in. If the grant is missing, deploy returns a 403 and reminds you how to authorize.
odyc-cli deployodyc.json:
{
"gameId": "...",
"slug": "..."
}Options:
-h, --help- Show help for deploy command
Sign in to your Odyc account using the OAuth 2.1 device authorization flow. The CLI prints a verification URL and a code, then waits while you authorize. Press ENTER to open the URL in your browser, or open it yourself β polling starts immediately either way. Credentials are stored locally in your OS config directory (auth.json) with owner-only permissions.
Signing in also authorizes code deploys for all of your games via a Rich Authorization Request (type: game, actions: [code.write], identifier: *), so no per-game authorization step is needed.
odyc-cli loginOptions:
-h, --help- Show help for login command
Show the currently signed-in account by fetching details from the OAuth /userinfo endpoint. Expired sessions are refreshed automatically when possible.
odyc-cli whoamiOptions:
-h, --help- Show help for whoami command
Sign out by revoking the current tokens at the authorization server (best effort) and removing the locally stored credentials.
odyc-cli logoutOptions:
-h, --help- Show help for logout command
odyc-cli/
βββ cmd/ # Commands implementation
βββ .github/ # GitHub Actions workflows
βββ main.go # Application entrypoint
The CLI is built using the Cobra framework for command-line interface management and charmbracelet/log for beautiful terminal logging.
Core Components:
- Main Entry Point (
main.go): Sets up logging styles and executes commands - Root Command (
cmd/root.go): Defines the base CLI structure and help information - Commands (
cmd/*.go): All available commands
- Go 1.24 or higher
- golangci-lint (for linting)
- Git
-
Fork and Clone
git clone https://github.com/YOUR_USERNAME/odyc-cli.git cd odyc-cli -
Install Dependencies
go mod download
-
Build and Run
go build -o odyc-cli . ./odyc-cli --help
# Build binary
go build -o odyc-cli .
# Run all tests
go test ./...We use go fmt to ensure consistent code formatting.
# Format all Go files
go fmt ./...We use golangci-lint for comprehensive code linting.
# Install golangci-lint (if not already installed)
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run linter
golangci-lint runOur CI/CD pipeline includes:
- Format Check: Ensures all Go code is properly formatted with
go fmt - Lint Check: Runs
golangci-lintto catch potential issues and enforce coding standards - Automated Testing: Runs on every push and pull request to
mainanddevelopbranches
We welcome contributions! Please see our Contributing Guide for details on how to:
- Report bugs and request features
- Submit pull requests
- Follow our coding standards
- Set up your development environment
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
This project is licensed under the MIT License - see the LICENSE file for details.
- Go - The programming language used to build CLI tool
- Cobra - Powerful CLI framework for Go
- Charmbracelet Log - Beautiful structured logging
- Charmbracelet Lipgloss - Style definitions for terminal UIs
- Testify - Testing toolkit with assertions and mocks
- golangci-lint - Comprehensive Go linter
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue if your problem isn't already reported
- Follow the issue template to provide necessary details
Made with β€οΈ for the Odyc.js community
