Spyglass-CLI
Introduction
spyglass-cli is a command-line interface (CLI) tool written in Rust, designed to provide type-safe helpers for working with substreams, specifically when using substreams to sink into a subgraph. This tool lets users seamlessly integrate with and generate helpers from different formats such as .spkg and .graphql.
Features
- Generate Rust code from
.spkgand.graphqlfiles. - Type-safe interactions with subgraphs, no more crashes at runtime!
- Efficient schema parsing and code generation for GraphQL schemas.
Installation
To get started with spyglass-cli, make sure you have Rust and Cargo installed. If you haven't installed Rust, refer to the official installation guide.
Once Rust and Cargo are set up simply run:
Usage
Using spyglass-cli is straightforward. Here's a quick guide:
Generate Command
Generates Rust code from the provided .spkg or .graphql input file.
spkg_or_graphql_path: The path to the input.spkgor.graphqlfile.--output-dir: (Optional) The directory where the generated Rust code will be saved. Defaults to./src/spyglass/.
Examples:
To generate code from a .spkg file:
To generate code from a .graphql file and specify an output directory:
Dependencies
clap: For parsing and handling command line arguments.nom: Used for working with byte-level and streaming data.prost: A Protocol Buffers implementation for encoding/decoding.anyhow: For easy error handling.syn: A parsing library for Rust source code.prettyplease: A utility for generating prettified Rust code.
Contribute
We welcome contributors to spyglass-cli! Feel free to fork the repository, make changes, and submit pull requests. Make sure to follow the Rust code guidelines and maintain the overall architecture and design of the tool.
About
Author: Alexander Gusev
Version: 0.1.0