22 lines
1020 B
Markdown
22 lines
1020 B
Markdown
# 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 of `Open` or `Close`)
|
|
- A `drawer_file` (`Path` for the drawer file to open or close)
|
|
- A `key_path` (`Path` to the key we'll use, which is either the value of the `-i` flag or the value of the `$DRAWER_KEY`
|
|
env var)
|
|
- A `target_path` (`Path` to the contents we're going to put into or take out of the drawer)
|
|
- A `force` (bool for whether or not `-f` was 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 `open` or `close`
|
|
- Passing any flags but `-f` or `-i`
|
|
- Not passing `-i` when the `$DRAWER_KEY` environment variable is undefined
|