Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script friendly output via a flag #18

Open
wraithan opened this issue Jan 27, 2019 · 2 comments
Open

Script friendly output via a flag #18

wraithan opened this issue Jan 27, 2019 · 2 comments

Comments

@wraithan
Copy link
Owner

wraithan commented Jan 27, 2019

This was proposed as --print to print the new version number alone on a new line in #7.

Before starting to add workspace support this seemed like a good idea. Unfortunately, this very simple output doesn't allow for multiple packages to be updated, since there is no way to distinguish them.

Surveying what other cargo tools do, the biggest one folks seem to wrap is cargo_metadata which by default outputs JSON. With that in mind, perhaps we need a few output types:

  • human - This output type will be default, it will likely be more verbose and include symbols to look nicer.
  • simple - This output type is basically a whitespace separated vector, $crate_name $old_version $new_version. This should be easily pulled apart in bash/powershell scripts used in CI systems.
  • json - This output type is to copy cargo_metadata, would be something like:
    [{"name": "cargo-bump", "old_version": "1.0.2", "new_version": "2.0.0"}]
  • ndjson - This output type would basically be the above but instead of wrapping in an array, new line delimit the JSON.

This could be done as a --output $TYPE option.

We should probably try to use the same setup for JSON that cargo_metadata is using, so I don't have multiple JSON deserializers in the binary. There are already 2 TOML serializers and deserializers because we need to retain formatting, no reason to also bloat for JSON.

@kornelski
Copy link

I suggest always printing the version exactly as in Cargo.toml. For workspaces, the -p package could be used to specify exact path, otherwise the nearest Cargo.toml should be used (that's Cargo's behavior).

@wraithan
Copy link
Owner Author

And when someone runs cargo bump major --all --print ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants