Conversation
Aims for saner defaults & to match `cargo update` behavior
af5718a to
aa5dfc7
Compare
| /// Path to the manifest to add a dependency to. | ||
| #[structopt(long = "manifest-path", value_name = "path", conflicts_with = "pkgid")] | ||
| pub manifest_path: Option<PathBuf>, | ||
| #[structopt(flatten)] | ||
| pub manifest: clap_cargo::Manifest, |
There was a problem hiding this comment.
Could you focus the PR, or at least the commits, to only porting to one clap_cargo feature at a time? It'll make it easier to see the impact.
There was a problem hiding this comment.
I'll implement Workspace, Features & Manifest in 3 separate commits, right?
There was a problem hiding this comment.
That works!
Separate PRs are nice because
- This project is configured for squash-merge only and separate PRs will preserve the distinction
- If there are easier / harder parts, we can get the easier parts through more quickly, allowing developing more incrementally rather than everything having to be ready at once
Separate commits are nice because
- Its easier to iterate on all the parts without any blockage due to PR reviews.
There was a problem hiding this comment.
@epage I'll work in this PR for now, maybe later I'll change my mind & file another 2 PRs.
| pub no_default_features: bool, | ||
| /// For an alternative approach to enabling features, consider installing `cargo-feature`. | ||
| #[structopt(flatten)] | ||
| pub features: clap_cargo::Features, |
There was a problem hiding this comment.
This added an all_features that is going unused. I think that will be confusing to users.
| let manifest_path = if let Some(pkgid) = args.workspace.package.get(0) { | ||
| let pkg = manifest_from_pkgid(args.manifest.manifest_path.as_deref(), pkgid)?; | ||
| Cow::Owned(Some(pkg.manifest_path.into_std_path_buf())) | ||
| } else { | ||
| Cow::Borrowed(&args.manifest_path) | ||
| Cow::Borrowed(&args.manifest.manifest_path) | ||
| }; |
There was a problem hiding this comment.
- This is ignore
exclude,all, andworkspacearguments - This is ignoring all other
packagevalues
If it isn't mapping well to add, its ok if we don't use clap_cargo
There was a problem hiding this comment.
@epage I think adding the same dependency to multiple crates in a workspace could be useful. I've made itpackage.get(0) just to make the code compile. It will be changed to processing the whole vector.
There was a problem hiding this comment.
It might be worth breaking that out into its own PR, after this one is done, so we can focus on one user-facing aspect at a time (existing multi-crate behavior vs making another command multi-crate)
| let manifest_path = if !args.workspace.package.is_empty() { | ||
| let pkg = manifest_from_pkgid(args.manifest.manifest_path.as_deref(), &args.workspace.package[0])?; | ||
| Cow::Owned(Some(pkg.manifest_path.into_std_path_buf())) | ||
| } else { | ||
| Cow::Borrowed(&args.manifest_path) | ||
| Cow::Borrowed(&args.manifest.manifest_path) | ||
| }; |
| let all = workspace || all || LocalManifest::find(&None)?.is_virtual(); | ||
|
|
||
| let manifests = if all { | ||
| Manifests::get_all(&manifest_path) | ||
| } else if let Some(ref pkgid) = pkgid { | ||
| Manifests::get_pkgid(manifest_path.as_deref(), pkgid) | ||
| } else if let Some(id) = pkgid.get(0) { | ||
| Manifests::get_pkgid(manifest_path.as_deref(), id) | ||
| } else { | ||
| Manifests::get_local_one(&manifest_path) | ||
| }?; |
There was a problem hiding this comment.
The intention of using clap-cargo is we defer to it for interpreting the combination of flags.
See https://docs.rs/clap-cargo/0.6.1/clap_cargo/struct.Workspace.html#method.partition_packages
There was a problem hiding this comment.
Yeah, I've seen this function & indend to use it, but as I've said this PR is in early stage. I've created it just to make sure other people know I'm working on it & wouldn't do duplicate work. Marked it draft & placed "work in progress" notice in the body. Anyway, thanks for your review comments.
| let manifests = if all { | ||
| Manifests::get_all(&manifest_path) | ||
| } else if let Some(ref pkgid) = pkgid { | ||
| Manifests::get_pkgid(manifest_path.as_deref(), pkgid) | ||
| } else if !pkgid.is_empty() { | ||
| Manifests::get_pkgid(manifest_path.as_deref(), &pkgid[0]) | ||
| } else { | ||
| Manifests::get_local_one(&manifest_path) | ||
| }?; |
There was a problem hiding this comment.
ditto about using partition_packages
|
@epage this PR is in very early stage, so don't expect too much 🙂 |
| /// Check if local manifest is virtual, i. e. corresponds to workspace root | ||
| pub fn is_virtual(&self) -> bool { | ||
| !self.data["workspace"].is_none() | ||
| } | ||
|
|
||
| /// Write changes back to the file | ||
| pub fn write(&self) -> Result<()> { | ||
| if self.manifest.data["package"].is_none() && self.manifest.data["project"].is_none() { | ||
| if !self.manifest.data["workspace"].is_none() { | ||
| if self.is_virtual() { |
There was a problem hiding this comment.
Please revert this. The function is_virtual, on its own, isn't correctly reporting virtual packages, only workspace roots. Its only virtual when combined with the preceding checks
There was a problem hiding this comment.
Surely, it will be replaced with something using partition_packages.
| url = "2.1.1" | ||
| ureq = { version = "1.5.1", default-features = false, features = ["tls", "json", "socks"] } | ||
| pathdiff = "0.2" | ||
| clap-cargo = "0.6.1" |
There was a problem hiding this comment.
I just released 0.7 to add the -p flag which was missing. We'll want this to not have a regression in people's workflows
There was a problem hiding this comment.
@epage we probably should also add structopt...conflicts_with to clap-cargo, as currently nothing prevents you from passing --workspace, --all & -p simultaneously.
There was a problem hiding this comment.
These are not conflicting in cargo so by using clap-cargo, we'll be better aligning in our behavior in this way as well.
Thats fine; just figured it'd help to give coordinate along he way so we can catch problems early (like me needing to fix some things in |
|
@epage I've just noticed you are the author of |
Yeah, I created it after |
Work in progress. See #535 (comment)
--workspacewhen running in workspace rootclap-cargo