Skip to content

Accept stdin for cargo update #15385

Open
@asasine

Description

@asasine

Problem

Hello! I'm writing a tool that updates the lock file for the set of git dependencies that all belong to a specific GitHub org. Rather than expect such a niche feature from Cargo itself, my plan was to use command chaining and cargo_metadata by filtering the resolved graph to the desired set and piping the package IDs into cargo update.

Proposed Solution

Add a feature to cargo update [spec...] such that spec... can be taken from stdin, allowing for chaining commands. Either spec... can be -, forcing stdin, or cargo update can default to stdin if spec... is empty and stdin is connected to a pipe.

Adding a --stdin flag would also be acceptable, leaving [spec...] untouched. The behavior would be the same (read [spec...] from stdin).

cargo update would read stdin until EOF then process it as if it were equivalent to [spec...]

Notes

One solution that depends on more shell-specific features is nesting commands e.g., in Bash:

cargo update $(filter-deps 'SomeGitHubOrg')

however, I believe this is less portable than the alternative of chaining commands:

filter-deps 'SomeGitHubOrg' | cargo update

as this can be done without a shell too (e.g., using std::process::Command).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions