-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add initial library for file
resource
#225
Conversation
## PR Summary - Add code to compute checksums for SHA-1, SHA-256 and SHA-512 hash algorithms. - Add code to generalize checking the environment and prompting the user to attach a debugger. ## PR Context The `file_lib` contains the implementation for the `file` resource.
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.
add this project to build.ps1
so that it gets run by clippy pedantic
file_lib/src/debug.rs
Outdated
pub fn check_debug(command: &String) { | ||
if env::var("DEBUG_DSC").is_ok() { | ||
let debug_args: Vec<String> = env::var(DEBUG_ENV_VAR) | ||
.unwrap() | ||
.split(',') | ||
.map(|s| s.to_lowercase()) | ||
.collect(); | ||
|
||
if debug_args.contains(command) { | ||
eprintln!( | ||
"attach debugger to pid {} and press any key to continue", | ||
std::process::id() | ||
); | ||
loop { | ||
let event = event::read().unwrap(); | ||
if let event::Event::Key(_key) = event { | ||
break; | ||
} | ||
eprintln!("Unexpected event: {event:?}"); | ||
} | ||
} | ||
} | ||
} |
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.
We should probably pull this into it's own crate to be used by different projects within this repo, but that can be done as a separate PR
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 wasn't sure where to put it. I didn't know if it belonged in dsc_lib
or a standalone create, or something new like dsc_utils
, and figured we could move it later. I have a similar refactor a function for the common code for reading STDIN.
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.
@miroman9364 can you open an issue so we refactor that common code, probably a dsc_utils
crate makes sense.
Refactor duplicate code to take advantage of common `Digest` Co-authored-by: Steve Lee <slee@microsoft.com>
- added the `file_lib` project - list of projects was getting long, so refactored onto multiple lines (sorted project names)
Build file is updated, build and test clean. |
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, please open issue for the refactoring discussion
There's some clippy pedantic issues you need to fix. Run build.ps1 -clippy
locally
- Clippy was unhappy with names, potential panics, and moves. - There is a key release for the enter key already buffered when the application starts; ignore this.
PR Summary
PR Context
The
file_lib
contains the implementation for thefile
resource.PR Summary
PR Context