dttt/README.md
2025-04-22 10:23:23 +02:00

134 lines
2.9 KiB
Markdown

# dttt
A versatile command-line toolkit providing various utility functions.
## Installation
```bash
go install git.bits.studio/public/dttt@latest
```
Or clone the repository and build it manually:
```bash
git clone git.bits.studio/public/dttt
cd dttt
go build -o dttt
```
## Commands
### resize
Resize images to a specified width while maintaining aspect ratio.
```bash
dttt resize [input_file] [output_file] [width]
```
Example:
```bash
dttt resize input.jpg output.jpg 300
```
### convert
Convert images between different formats including JPG, PNG, and WebP.
```bash
# Single file conversion
dttt convert [input_file] [output_file]
# Batch conversion
dttt convert [input_directory] [output_directory] --batch --format [format]
```
The output format is determined by the output file extension (for single file conversion) or the `--format` flag (for batch conversion).
Options:
- `--quality, -q`: Quality for lossy formats (1-100, default: 90)
- `--batch, -b`: Enable batch conversion mode
- `--format, -f`: Output format for batch conversion (jpg, jpeg, png, webp)
- `--extensions, -e`: Comma-separated list of file extensions to process in batch mode (default: jpg,jpeg,png,webp)
Examples:
```bash
# Convert single JPG to WebP
dttt convert input.jpg output.webp
# Convert PNG to JPG with 80% quality
dttt convert input.png output.jpg --quality 80
# Convert WebP to PNG
dttt convert input.webp output.png
# Batch convert all JPG and PNG files in a directory to WebP
dttt convert ./photos ./webp_photos --batch --format webp --extensions jpg,png
# Batch convert all supported images to JPG with 85% quality
dttt convert ./input ./output --batch --format jpg --quality 85
```
### rename
Rename files in bulk based on specified patterns.
```bash
dttt rename --pattern "prefix_###.jpg" --start 1 --directory ./images
```
Options:
- `--directory, -d`: Directory containing the files to rename (default: current directory)
- `--pattern, -p`: Pattern for renaming files. Use '###' as a placeholder for numeric sequence
- `--start, -s`: Start index for numeric sequence in the renaming pattern (default: 1)
### server
Start a simple HTTP server to serve files from a specified directory.
```bash
dttt server [directory]
```
Options:
- `--port, -p`: Port number for the HTTP server (default: 8080)
If no directory is provided, the current directory is used.
### chat
Start a chat server or connect to other peers.
```bash
# Start a chat server
dttt chat
# Connect to a chat server
dttt chat localhost:8080
```
Options:
- `--nickname, -n`: Nickname for the user
### env
Manage environment variables.
```bash
# List all environment variables
dttt env list
# Set an environment variable
dttt env set KEY VALUE
# Unset an environment variable
dttt env unset KEY
```
## Configuration
You can specify a configuration file using the `--config` flag. By default, the configuration is read from `$HOME/.dttt.yaml`.
## License
See the [LICENSE](LICENSE) file for details.