-
Notifications
You must be signed in to change notification settings - Fork 27
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
chore: support specify contract path input with or without -p flag #361
Conversation
Thanks for your interest in contributing to |
Hello, I looked into it, and it seems to me that what we're trying to do is closer to this, and this. |
@AlexD10S , I made a cleaner version of my first suggestion (modifications are minimal, and limited to |
Thanks! Running the CI to check all tests pass, and I'll do a proper review |
I saw that the CLI was failing, and did a |
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #361 +/- ##
==========================================
- Coverage 75.15% 75.11% -0.05%
==========================================
Files 62 62
Lines 13820 13849 +29
Branches 13820 13849 +29
==========================================
+ Hits 10386 10402 +16
- Misses 2082 2097 +15
+ Partials 1352 1350 -2
|
Any update? should I propagate the modification to |
Sorry for the delay, we have been readying a release. @AlexD10S could you provide some feedback on next steps here please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for sharing these resources! They were very helpful in understanding the best approach. While I'm not thrilled about it, it seems that keeping the two arguments is the most practical solution, great job.
A couple of quick changes:
If you run pop
in your parachain or contract folder, there’s no need to specify the path. That's why we changed the argument to Option.
You could remove required_unless_present
and probably makes sense to use index = 1
.
It might also be helpful to add conflicts_with = "path"
so that users don’t accidentally specify both positional and named paths, like this:
pop build ../my_contract --path ../my_contract_2
Here's an example of how the argument definition could look:
/// Directory path without flag for your project [default: current directory]
#[arg(value_name = "PATH", index = 1, conflicts_with = "path")]
pub(crate) path_pos: Option<PathBuf>,
Finally, with this optional path in mind, the code where you determine project_path can be simplified to something like this:
let project_path = if let Some(path_pos) = args.path_pos {
Some(path_pos) // Use positional path if present
} else {
args.path // Otherwise, use the named path
};
Great work so far, and thank you for your patience while I got around to reviewing this! Apologies for the delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
I left some comment mainly to refactor repetitive code.
The important thing to fix are the unit tests that are failing. I think it can be because you specify both path
and path_pos
in the tests and then the result is not the expected.
Review the tests and adjust it. I'd probably leave path
and path_pos
to None in most of the tests except one where use path_pos
or have a specific one to test the path_pos
functionality
You can test them locally with: cargo test --lib --bins
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes! I noticed the CI is failing because the get_project_path function, used for both contracts and parachain, was moved to a file that only works under the contracts feature, see: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/src/common/mod.rs#L3
you can test it with: cargo check --no-default-features --features parachain
You can fix this by either removing the line above or, better yet, moving the function to a shared file under common (maybe a new build.rs).
Also, please add comments to the method.
@AlexD10S , I see that all CI checks are passing: what's next? |
Alex is OOO today, so expect a response when he is back tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Everything looks excellent. Thank you for your patience and effort in addressing all the requested changes.
Description
This PR is addressing issue #350.
Allow
pop-cli
to supports two ways to to specify the path to a contract or artifact file: using the-p
flag or specifying the path directly without it:and
should both be possible.
Implementation
Two arguments are used to specify the path: One Optional, and one positional:
The following contract-related commands will be upgraded