major changes

This commit is contained in:
2026-09-16 23:31:13 +05:30
parent 4e40263f69
commit ecb149971b
16 changed files with 500 additions and 117 deletions
+184 -19
View File
@@ -1,37 +1,202 @@
# unique
A utility that appends a suffix to files and folders to ensure name uniqueness.
A small but practical command-line utility for creating safe, unique file and directory names.
## Building from source
When scripts, backups, content pipelines, or file-based workflows need to create or rename paths
without collisions, `unique` appends a timestamp-, UUID-, or entropy-based suffix to keep names
distinct, readable, and easy to trace.
### 1. Virtual Environment
## Why use unique?
Create a virtual environment for Python, and activate the same.
File naming collisions are a recurring problem in scripting, automation, backups, content pipelines,
and content authoring workflows. `unique` gives you a simple interface to:
```sh
- create a new file or directory with a guaranteed unique name
- rename an existing path to have a unique name
- duplicate a file while preserving its original contents under a fresh name
- choose the suffix generation method that best fits your workflow
## Features
- Create files or directories with unique names
- Rename existing files or folders safely
- Duplicate files with a unique derivative name
- Multiple suffix strategies:
- `datetime`
- `epoch`
- `uuid`
- `uuid7`
- `uuid-b36`
- `uuid7-b36`
- Python-based CLI design for simple automation and scripting
## Documentation
- [Build from Source](docs/build-from-source.md) — set up the project and produce a distributable build.
- [Using unique](usage.md) — learn the CLI commands and examples.
## Installation
### Prerequisites
- Python 3
- `pip`
### Set up a virtual environment
```bash
python3 -m venv .venv
source .venv/bin/activate
```
### 2. Resolve Dependencies
### Install dependencies
Unique has a dependency on Scott: a framework to create scoped task-oriented terminal tools. To resolve this, run:
```sh
```bash
pip install "git+https://rprime.indroneel.co/termhole/scott.git"
```
For older versions of Python, Unique has a dependency on a backported UUID library:
```sh
pip install uuid6
```
### 3. Installing the Application
### Install the project
To install `unique` in the virtual environment, run:
```sh
```bash
pip install -e .
```
You can then invoke the CLI as:
```bash
unique --help
```
## Usage
The CLI is organized around a small set of commands.
### Create a unique file
```bash
unique create --file notes.txt
```
Example result:
```text
notes-20260916-153425.txt
```
### Create a unique directory
```bash
unique create --dir project
```
Example result:
```text
project-20260916-153425
```
### Rename an existing file or directory
```bash
unique touch report.md
```
This appends a generated suffix to the original path instead of overwriting an existing file.
### Duplicate a file with a unique name
```bash
unique duplicate ./archive.tar.gz
```
Example result:
```text
archive-20260916-153425.tar.gz
```
## Suffix methods
You can control the suffix algorithm with the `--method` option:
```bash
unique create --file draft.txt --method uuid7
```
Available methods:
- `datetime` — current date and time
- `epoch` — Unix timestamp in milliseconds
- `uuid` — UUID v4
- `uuid7` — UUID v7
- `uuid-b36` — base36 UUID representation
- `uuid7-b36` — base36 UUID v7 representation
## Command reference
### `unique create`
Create a file or directory with a unique name.
```bash
unique create PATH --file|--dir [--method METHOD]
```
### `unique touch`
Rename an existing file or directory to a unique variant.
```bash
unique touch PATH [--method METHOD]
```
### `unique duplicate`
Create a copy of an existing file with a unique name.
```bash
unique duplicate PATH [--method METHOD]
```
## Examples
```bash
# Create a unique file using a UUID v7 suffix
unique create --file draft.md --method uuid7
# Create a unique directory using the current timestamp
unique create --dir content --method datetime
# Rename an existing file to a unique version
unique touch ./notes.txt --method epoch
# Duplicate a file without clobbering the original
unique duplicate ./backup.db --method uuid-b36
```
## Project layout
```text
unique/
├── LICENSE
├── README.md
├── pyproject.toml
├── unique.spec
├── src/
│ └── unique/
│ ├── commands/
│ ├── lib/
│ └── main.py
└── .venv/
```
## License
This project is licensed under the terms of the repository license. See [LICENSE](LICENSE) for details.
## Notes
This project is intentionally compact and script-friendly: it focuses on one task well—creating unique names for paths—while leaving room for automation in shell scripts, build tooling, and content workflows.
If you want to package it into a standalone executable, the repository includes a PyInstaller spec file at [unique.spec](unique.spec).