-
Notifications
You must be signed in to change notification settings - Fork 409
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
reading the cargo toml 2x is kinda gross #25
Comments
You could read it in via |
Once #66 lands this will already have lazy_static installed so the steps for that would then be:
It's a small issue, but it'll let you get acquainted with the code base and make things more efficient! :D |
yesss |
#66 landed so this is all good to hack on now :D |
Hi! I'd love to help out with this issue. I can start working on this today, and follow up if I have any further questions 😄 |
I had a question about I see how this could be done by reading the |
The path is also not constant. I'm a neewb so I'm unsure of how to access it in the |
I took a swing at this! I wasn't able to figure out how to use |
@data-pup I had a whole answer then realized what you meant. I tested this out quickly so I know I won't be sending you down the wrong path. I'll just let you do it and learn! :D So the big problem here is that there is a lib.rs and a main.rs file. You can't access the manifest file and the path handed to the program without knowing the arguments. They actually shouldn't be separate for a commandline project like this. Here's what you'll need to do to get this working:
So in the block for it you'll need something like this: let x = Cli::from_args();
match x.cmd {
Command::Init { path, scope } => {
// Read the file here with the path and return the string
},
// Match the other ones here, see below in main.rs for help on how too
} Path is an Then proceed with the other instructions. Thanks for pointing this out I didn't realize this was going to be an issue when making the instructions. This should do it based off the quick protoype I whipped up but it was more just checking that you could do the args in lazy_static so no file reading or anything. Try this out and if it works send a PR in and we can do a review and help you polish and clean any rough edges! :D If this isn't detailed enough or you need more clarity please let me know :D |
@data-pup I also just saw your comment after typing this out. That also works as a solution, but we're adding more argument calls to functions, which we can avoid here with lazy-static. It'll help keep our signature functions less "noisy" and allow us to easily use that data in other places later on. Try the above out and if that's still not possible at all then lets go this route, but I'm certain we can get it working with lazy-static :) |
hey friends, i'm gonna put a hold on this issue. i don't want to get rid of lib... it's literally the entire strategy behind how this application is tested so we can't get rid of it! gimme a sec to think and i'll let ya know. |
@mgattozzi Thanks for following up, that makes sense to me! Definitely agree about the fact that adding arguments seemed kind of noisy. I'll hold up on this for now, per Ashley's comment above, but I would love to help out once a strategy is decided on :) |
thanks so much for your efforts and patience @data-pup ! i'll def ping u once we figure out what we want here, i think i'm bumping into a frustration have with testing rust binaries ;) we'll see how i sort that |
Of course! Sounds good to me : ) Good luck! |
In the meantime if there's another issue you want to take a crack at definitely do so! :D |
oh yeah plz @data-pup - even if it isn't marked as helpwanted or good first issue, lemme know and we'll get u set up with it. i feel bad about this sitch :( <3 and want u to get a chance to contribute! |
to lib.rs to hopefully allow for better use of lazy_static as discussed in issue rustwasm#25
@ashleygwilliams is this something that is ready for work? I would love to try and tackle this |
@bringking i believe after several refactors we should be able to tackle this- that being said @data-pup had originally tried to tackle this, so i'd like to give them right of first refusal before someone else takes it on- what do you think @data-pup ? |
Hey! I would love to take another swing at this :) |
@ashleygwilliams okay cool, works for me 😃 |
@bringking There are definitely other issues open to work on! If you see one that catches your interest say you are and we can write out instructions on whatever needs to be done to get it working if you need them :D |
@mgattozzi I tried to add a static
Let me know if you have any advice, otherwise I think I'll try and work on some other issues in the meantime :) |
Hmmm so cloning is basically happening which is essentially reading it twice. Since we're just serializing data which only requires a reference we could get npm to just hold &str instead of String. Rather than it taking ownership it borrows so this should work! Also in the case of it not failing when initializing, have it be a Result and just use ? in both places it's called! |
Ah neat! That makes sense, I’ll try that out tonight 🙂 |
Turning the static variable into a
I found some advice online elsewhere saying something like The other problem I was seeing is that this approach would break the |
Ah okay. I had a very busy weekend so I'm just getting around to this. Do you have the code up somewhere? I can take a look and see if there's a way around the weirdness. There's a lot of things lazy_static does to do what it does and occasionally you run into problems like this. |
No worries! I have a branch on my fork of this repo with my work on this here. I was noticing that about lazy_static, it’s actually a really neat macro! Troubles aside, glad I’ve been able to learn more about it bc of this 🙂 |
@data-pup it's a real neat macro and one of my favorites. I'll take a look at this tonight. |
This issue is reserved for someone who has not yet contributed to this codebase.
Currently we read the Cargo.toml twice! this is not preferred:
MENTORING INSTRUCTIONS (from @mgattozzi !):
Cargo.toml
file to aString
and assign it to a variable, maybe something likeCARGO_TOML
The text was updated successfully, but these errors were encountered: