Create a command-line program that accepts an optional argument: “-d path”. If the path is not supplied, it defaults to “~/inbox/”. If the path does not exist, it should be created. We refer to this path as “INBOX” in the rest of the document.
Program workflow:
- Scan the folder recursively and print to stdout all the files found and their last modification date in the following format: “[Date Time] PATH”, where PATH is a relative path to INBOX.
- Start monitoring INBOX for file changes. When an event occurs, print it to stdout in the following format: “[EVENT] PATH”, where EVENT is one of the following [NEW, MOD, DEL].
- Continue monitoring until the user inputs Ctrl-C.
- Once Ctrl-C is detected, print to stdout the contents of INBOX again in the same format, without rescanning or any other FS operations.
Bonus points for:
- Using tokio
- Using structured error handling
- Not using mutexes
- Having separation of concerns