feat!: consolidate cot cli commands into one#587
Open
ElijahAhianyo wants to merge 15 commits into
Open
Conversation
|
| Branch | elijah/cot-proxy-cmd |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 5,606.60 µs(-9.60%)Baseline: 6,202.14 µs | 7,769.64 µs (72.16%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 998.73 µs(-7.70%)Baseline: 1,082.01 µs | 1,324.38 µs (75.41%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 951.40 µs(-5.20%)Baseline: 1,003.62 µs | 1,204.76 µs (78.97%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 925.39 µs(-4.20%)Baseline: 965.95 µs | 1,168.76 µs (79.18%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 17,133.00 µs(-2.63%)Baseline: 17,595.05 µs | 21,141.65 µs (81.04%) |
- help for workspaces and packages now dispatch to the custom help handler
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Background
cotcurrently exposes CLI commands through two separate entry points:cot-clicrate (cot <command>): handles project scaffolding, migration listing, migration generation, and shell completions.check, running migrations (which is also triggered implicitly at startup), and any custom user-defined task commands.In addition, running and building a
cotapp relies on Cargo tooling. In summary, there are three ways to invoke CLI commands today:cot <command>via thecot-clicratecot-cliThis PR focuses on unifying 1 and 2 for ergonomics:
cotnow acts as the single entry point for all commands, proxying any unrecognized command to the compiled binary if it exists there. Option 3 (Cargo invocation) is out of scope for this PR and can be revisited in a follow-up if proxying those commands makes sense.Approach
When
cotreceives a command it does not recognize, it resolves the target binary (target/debugby default, ortarget/releaseif--releaseis passed), queries it for its available commands via a metadata flag, and either forwards the command along with all provided arguments or returns an error if the command is not found in the binary either.Metadata
To support proxying, the
cotcrate exposes a--metadataflag. At runtime, the binary uses reflection to enumerate all registered CLI commands and prints them as JSON to stdout. This serves two purposes: it tellscot-cliwhether a given command should be forwarded, and it provides the information needed to render accurate help text.Example:
Caching
Querying the binary on every invocation would be wasteful, so the metadata response is cached in
.cot/command-cache.json. The cache stores the binary's modified time (mtime) alongside the metadata and is invalidated automatically whenever the binary is rebuilt.Workspaces
When working inside a Cargo workspace, a
--package(-p) flag must be provided to specify which package's binary should be targeted.Type of change