-
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
base: main
Are you sure you want to change the base?
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 74.29% 75.62% +1.33%
==========================================
Files 56 59 +3
Lines 11233 12725 +1492
Branches 11233 12725 +1492
==========================================
+ Hits 8345 9623 +1278
- Misses 1746 1806 +60
- Partials 1142 1296 +154
|
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
.
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