1020 B
1020 B
Phase 1
Write code that uses clap to parse the command line arguments and create a DrawerOperation struct from them. The
DrawerOperation struct will contain:
- An
operation_type(OperationType, enum ofOpenorClose) - A
drawer_file(Pathfor the drawer file to open or close) - A
key_path(Pathto the key we'll use, which is either the value of the-iflag or the value of the$DRAWER_KEYenv var) - A
target_path(Pathto the contents we're going to put into or take out of the drawer) - A
force(bool for whether or not-fwas passed)
In order for this to be testable, it needs to be a function that returns a Result<DrawerOperation, DrawerError>. The
main function should call that and then do nothing with the result.
Certain things should cause the function to return Err:
- Not passing a drawer file
- Passing a subcommand other than
openorclose - Passing any flags but
-for-i - Not passing
-iwhen the$DRAWER_KEYenvironment variable is undefined