-
Notifications
You must be signed in to change notification settings - Fork 1
fix: replace regex with string operations #12
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
Conversation
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.
LGTM for the most part. Just wanna avoid having a runtime error happen if we get by index here.
src/client.rs
Outdated
|
||
for arg in args { | ||
if arg.starts_with("--remoting-auth-token") { | ||
let val = arg.split("=").collect::<Vec<&str>>()[1]; |
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.
mind getting rid of the index here?
let val = arg.split("=").collect::<Vec<&str>>().first();
let token = val.ok_or(Error::AppNotRunning);
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.
Yeah I'll change it no problem, though if I understand how args work it should always split into exactly 2 parts so this should still be fine I think.
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.
you're probably right. This is just the only thing that's bitten us at work lately so i try to avoid it as much as possible.
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.
Now that I changed it, it looks cleaner without indexing, plus it avoids needing to make a vector. I'm kind of new to rust still so I overcomplicate stuff like this a lot.
src/client.rs
Outdated
token = Ok(val); | ||
} | ||
if arg.starts_with("--app-port") { | ||
let val = arg.split("=").collect::<Vec<&str>>()[1]; |
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.
same here.
Cool thanks! |
Resolves #11