gnd: Add gnd indexer command that delegates to graph-indexer#6492
Open
dimitrovmaksim wants to merge 1 commit intographprotocol:masterfrom
Open
gnd: Add gnd indexer command that delegates to graph-indexer#6492dimitrovmaksim wants to merge 1 commit intographprotocol:masterfrom
gnd indexer command that delegates to graph-indexer#6492dimitrovmaksim wants to merge 1 commit intographprotocol:masterfrom
Conversation
Adds an `Indexer` subcommand to gnd that forwards commands to the `graph-indexer` binary from the `indexer-cli` npm package. This lets users run indexer management commands (allocations, rules, cost models, etc.) directly through gnd. - `version`, `help` and their short forms are forwarded as top-level commands; all other subcommands get the `indexer` namespace prepended (required by graph-indexer's Gluegun plugin system) - `--help` is handled by clap (works without graph-indexer installed) - On Unix, uses exec() for clean signal forwarding and exit codes - Clear error message when graph-indexer is not on $PATH
5bf56ef to
6023470
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
Adds
gnd indexercommand that delegates tograph-indexer(@graphprotocol/indexer-cli), allowing users to manage indexer operations (allocations, rules, cost models, status, etc.) directly through gnd.graph-indexerpreviously integrated intograph-clias plugin, but now that integration seems to be broken.Design decisions
Why not clap's external_subcommand?
Clap's
external_subcommandattribute is a catch-all that captures any unrecognized subcommand into a Vec. Unlike cargo's external subcommand convention (cargo fmt → cargo-fmt) or Gluegun's plugin system (which auto-discovers and loads plugins at runtime), clap'sexternal_subcommanddoesn't perform any binary resolution — it just captures raw args and leaves dispatch to you.I considered using it but chose an explicit Indexer variant instead because:
external_subcommandcatch-all.graph-indexer. A catch-all would accept any unknown subcommand and produce confusing "binary not found" errors for typos.Gluegun namespace prefix
graph-indexeruses Gluegun's plugin system whereindexeris the plugin namespace. All management commands requiregraph-indexer indexer <subcommand>(e.g.graph-indexer indexer allocations get). We prependindexerautomatically so users writegnd indexer allocations getinstead of the longer form.Exceptions:
version/v/--version/-vandhelp/hare top-level commands in graph-indexer and are forwarded without the indexer prefix.Help delegation: --help vs help
There are two help paths with different behavior:
gnd indexer --helpvsgnd indexer help--helpis intercepted by clap before args reachrun_indexer(). This is intentional as it provides basic usage information even when graph-indexer is not installed.help(without dashes) passes through to graph-indexer and shows the full command list.No-args handling
When
gnd indexeris invoked with no arguments, we passhelptograph-indexerto show its top-level help.Exit codes
Exit codes from
graph-indexerare passed through as-is, which may differ from gnd's documented 0/1 convention. This is documented in the migration guide. Reason is to not breake existing scripts that may await the current exit codes.