Overview
cloneit can automatically create zip archives of downloaded content using the-z flag. This feature is useful for archiving, distribution, or when you need compressed versions of GitHub repositories or directories.
The zip archive functionality was implemented by @winterrdog.
Basic Usage
Add the-z or --zip flag to any cloneit command:
cloneit.zip in your current directory.
How It Works
When you use the-z flag, cloneit:
- Validates the GitHub URL
- Downloads the directory or file
- Creates the local file structure
- Zips the downloaded content
- Creates a
.zipfile named after the root directory
Process Steps
With the-z flag, you’ll see additional steps in the output:
Zipping Directories
Zip an entire repository:- Downloaded directory:
cloneit/ - Zip archive:
cloneit.zip
- Downloaded directory:
src/ - Zip archive:
src.zip
Zipping Individual Files
The-z flag also works with single files:
Archive Naming
The zip file is automatically named based on the root directory:Examples
| Command | Directory Created | Zip Archive |
|---|---|---|
cloneit -z https://github.com/user/repo | repo/ | repo.zip |
cloneit -z https://github.com/user/repo/tree/main/src | src/ | src.zip |
cloneit -z https://github.com/user/repo custom-name | custom-name/ | custom-name.zip |
Multiple URLs with Zip
You can zip multiple downloads in one command:repo1/andrepo1.ziprepo2/andrepo2.zip
Combining Flags
Combine-z with other flags for additional control:
Quiet Zip Mode
Custom Path with Zip
- Downloaded directory:
my-archive/ - Zip archive:
my-archive.zip
Technical Implementation
The zipping process is handled by theZipArchiver in src/file_archiver.rs:
- Takes the root directory path
- Creates a zip file with the same name
- Recursively adds all files and directories
- Preserves the directory structure within the archive
Error Handling
File Not Found Error
Zip Creation Errors
Other zip-related errors are displayed with full error messages from the zip library.Use Cases
Archive Code Snippets
Quickly archive specific directories for reference:Distribution
Create distributable archives:Backup
Backup specific repository versions:Offline Access
Download and compress for offline viewing:File Structure in Archive
The zip archive preserves the exact directory structure:Next Steps
- Learn about downloading multiple URLs
- Explore basic usage patterns
- Understand directory downloads