Architecture — CLI Client (client/)
The Plik command-line client. For system-wide overview, see the root ARCHITECTURE.md.
Structure
client/
├── plik.go ← main CLI logic (docopt-based argument parsing + upload flow)
├── config.go ← configuration loading (.plikrc)
├── progress.go ← upload progress bar
├── update.go ← self-update mechanism
├── archive/ ← archive backends (tar, zip)
├── crypto/ ← crypto backends (openssl, pgp)
├── .plikrc ← example client configuration
├── plik.sh ← bash upload wrapper
├── test.sh ← CLI integration tests
├── test_downgrade.sh ← client version downgrade tests
└── test_upgrade.sh ← client version upgrade testsKey Components
CLI Entry Point (plik.go)
Uses docopt-go for argument parsing. The main flow:
- Parse CLI args (file paths, options like
--oneshot,--stream,--ttl, etc.) - Load config from
.plikrc(orPLIKRCenv var) - Handle special modes:
--update(self-update),--version - Create upload via the Go library (
plik/) - Add files (with optional archive/encrypt preprocessing)
- Upload files with progress bars
- Print download URLs
Configuration (config.go)
Config is a TOML file loaded from (in order):
PLIKRCenvironment variable~/.plikrc/etc/plik/plikrc
Key config fields: URL (server), Token (upload token), archive/crypto defaults.
Archive Backends (archive/)
| Backend | Description |
|---|---|
tar | Create tar archives with compression (gzip, bzip2, xz, lzip, lzma, lzop) |
zip | Create zip archives |
Archives wrap multiple files/directories into a single upload file.
Crypto Backends (crypto/)
| Backend | Description |
|---|---|
openssl | Symmetric encryption via OpenSSL CLI (configurable cipher) |
pgp | Asymmetric encryption via GPG/PGP (recipient-based) |
Encryption wraps the file data stream before upload.
Self-Update (update.go)
The client can update itself by downloading the latest matching binary from the configured Plik server. It compares versions and replaces the current binary in-place.
Integration Tests
test.sh— comprehensive CLI integration tests (requires a running server)test_upgrade.sh/test_downgrade.sh— version compatibility tests (stale, unused since ~2021)
