# 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 `.spkg` and `.graphql` files.
- 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](https://www.rust-lang.org/tools/install).
Once Rust and Cargo are set up simply run:
```bash
$ cargo install spyglass-cli
```
## Usage
Using `spyglass-cli` is straightforward. Here's a quick guide:
### Generate Command
Generates Rust code from the provided `.spkg` or `.graphql` input file.
```bash
$ spyglass-cli generate <spkg_or_graphql_path> [--output-dir <output_directory>]
```
- `spkg_or_graphql_path`: The path to the input `.spkg` or `.graphql` file.
- `--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:
```bash
$ spyglass-cli generate /path/to/file.spkg
```
To generate code from a `.graphql` file and specify an output directory:
```bash
$ spyglass-cli generate /path/to/file.graphql --output-dir /desired/output/dir/
```
## 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