feat(cli): add clap CLI with --config flag and listen subcommand#30
Merged
Conversation
Wire up the first runnable binary. `charon` now accepts:
--config / -c (defaults to config/default.toml)
listen (subcommand; real scanner arrives in Day 2)
On startup:
1. dotenvy loads `.env` if present (silent no-op otherwise)
2. tracing_subscriber configures structured logging
(RUST_LOG=debug to dial up verbosity)
3. Cli::parse() validates args via clap derive
4. Config::load() reads + substitutes + parses TOML; errors bubble
up with context about which file failed
5. Successful load logs a one-line summary (chain / protocol /
flashloan counts, min profit)
Also fix a parser/comment collision in config/default.toml: a doc
comment had a literal \${ENV_VAR} placeholder that the substituter was
picking up as a real env reference. Comment now describes the syntax
in prose.
cargo run -- --config config/default.toml listen now works
end-to-end after \`cp .env.example .env\`.
This was referenced Apr 22, 2026
…xplicit multi-thread flavor - tracing_subscriber writes to stderr so 'listen' can emit JSON on stdout later without interleaving log output into the data stream. - --config has no default; must come from --config flag or CHARON_CONFIG env var. Removes the cwd-relative 'config/default.toml' fallback that silently resolves wrong inside the Docker WORKDIR. - clap workspace feature set adds 'env' so the env = "CHARON_CONFIG" attr compiles. - Annotate the startup info! block with a SECURITY comment enumerating the fields that must never appear there (ws_url, http_url, private keys, wallet addresses, full Debug of Config / ChainConfig). - Long-running listen now runs inside tokio::select! with SIGINT (ctrl_c) and SIGTERM branches so docker stop → SIGTERM exits cleanly before the 10 s SIGKILL. wait_sigterm is cfg-gated for non-Unix targets. - #[tokio::main(flavor = "multi_thread")] makes the concurrency contract explicit and immune to future tokio feature-flag trimming. Closes #82 #83 #84 #85 #86
# Conflicts: # Cargo.lock # crates/charon-cli/Cargo.toml
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.
Closes #6
First runnable binary.
charonentrypoint with clap-based argument parsing and two subcommands:listen— placeholder for the scan loop (wired up in later PRs)test-connection --chain <name>— RPC health probeStructured logging via
tracing_subscriberwithRUST_LOGoverride.dotenvyauto-loads.envif present.Usage:
Depends on #5 (
feat/04-toml-config-loader).