Install

brew install p7zip

Extract

7z x file.7z

Compress

7z a file.7z mydirectory