updated project documentation
This commit is contained in:
@@ -21,182 +21,57 @@ and content authoring workflows. `unique` gives you a simple interface to:
|
|||||||
- Create files or directories with unique names
|
- Create files or directories with unique names
|
||||||
- Rename existing files or folders safely
|
- Rename existing files or folders safely
|
||||||
- Duplicate files with a unique derivative name
|
- Duplicate files with a unique derivative name
|
||||||
- Multiple suffix strategies:
|
- Multiple suffix strategies: `datetime`, `epoch`, `uuid`, `uuid7`, `uuid-b36`, and `uuid7-b36`
|
||||||
- `datetime`
|
|
||||||
- `epoch`
|
|
||||||
- `uuid`
|
|
||||||
- `uuid7`
|
|
||||||
- `uuid-b36`
|
|
||||||
- `uuid7-b36`
|
|
||||||
- Python-based CLI design for simple automation and scripting
|
- Python-based CLI design for simple automation and scripting
|
||||||
|
|
||||||
## Documentation
|
## Quick Usage
|
||||||
|
|
||||||
- [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
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install "git+https://rprime.indroneel.co/termhole/scott.git"
|
|
||||||
pip install uuid6
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install the project
|
|
||||||
|
|
||||||
```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.
|
The CLI is organized around a small set of commands.
|
||||||
|
|
||||||
### Create a unique file
|
**Create a unique file**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
unique create --file notes.txt
|
unique create --file notes.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
Example result:
|
This creates a new file with a name like `notes-20260916-153425.txt`
|
||||||
|
|
||||||
```text
|
**Create a unique directory**
|
||||||
notes-20260916-153425.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
### Create a unique directory
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
unique create --dir project
|
unique create --dir project
|
||||||
```
|
```
|
||||||
|
|
||||||
Example result:
|
This creates a new folder with a name like `project-20260916-153425`
|
||||||
|
|
||||||
```text
|
**Rename an existing file or directory**
|
||||||
project-20260916-153425
|
|
||||||
```
|
|
||||||
|
|
||||||
### Rename an existing file or directory
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
unique touch report.md
|
unique touch report.md
|
||||||
```
|
```
|
||||||
|
|
||||||
This appends a generated suffix to the original path instead of overwriting an existing file.
|
`report.md` must pre-exist. This appends a generated suffix to the original path instead of
|
||||||
|
overwriting an existing file.
|
||||||
|
|
||||||
### Duplicate a file with a unique name
|
### Duplicate a file with a unique name
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
unique duplicate ./archive.tar.gz
|
unique duplicate archive.tar.gz
|
||||||
```
|
```
|
||||||
|
`archive.tar.gz` must pre-exist. A copy of the file will be created with a name like
|
||||||
|
`archive-20260916-153425.tar.gz`
|
||||||
|
|
||||||
Example result:
|
|
||||||
|
|
||||||
```text
|
## Documentation
|
||||||
archive-20260916-153425.tar.gz
|
|
||||||
```
|
|
||||||
|
|
||||||
## Suffix methods
|
- [Build from Source](docs/build-from-source.md) — set up the project and produce a distributable
|
||||||
|
build.
|
||||||
You can control the suffix algorithm with the `--method` option:
|
- [Installation](docs/installation.md) — install the CLI tool and make it available from any
|
||||||
|
directory.
|
||||||
```bash
|
- [Using unique](docs/usage.md) — learn the CLI commands and examples for more detailed usage.
|
||||||
unique create --file draft.txt --method uuid7
|
- [Suffix methods](docs/suffix-methods.md) - the different strategies to generate a unique name.
|
||||||
```
|
|
||||||
|
|
||||||
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
|
## License
|
||||||
|
|
||||||
This project is licensed under the terms of the repository license. See [LICENSE](LICENSE) for details.
|
This project is distributed under the
|
||||||
|
[DuxTechnica Limited Use Source Code License Agreement](LICENSE).
|
||||||
## 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).
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
title: Installing Unique
|
||||||
|
---
|
||||||
|
|
||||||
|
# Installing Unique
|
||||||
|
|
||||||
|
`unique` is meant to be used as a command-line tool, not as a project-local script that must be run
|
||||||
|
from inside its source directory. For a developer workflow, the practical approach is:
|
||||||
|
|
||||||
|
1. Follow the instructions to [build from source](build-from-source.md), all the way to creating a
|
||||||
|
standalone executable. This executable should be available under the `dist/` directory under the
|
||||||
|
project root of `unique`.
|
||||||
|
|
||||||
|
2. Alternatively, download a pre-build copy of the executable for your operating system.
|
||||||
|
|
||||||
|
3. Copy the executable into a common location, so that you can delete the unique project folder at a
|
||||||
|
later point in time.
|
||||||
|
|
||||||
|
4. Install the executable for global CLI access. You can use a command from within `unique` to
|
||||||
|
complete the installation.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd /{folder-where-you-copied-the-executable}
|
||||||
|
./unique install
|
||||||
|
```
|
||||||
|
|
||||||
|
This command creates a symlink at `~/.local/bin/unique` that points to the built executable. After
|
||||||
|
that, the tool can be invoked from anywhere in your shell:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
unique --help
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
|
||||||
|
If `~/.local/bin` is not already on your `PATH`, add it:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
```
|
||||||
|
|
||||||
|
For persistence, add the same line to your shell profile, such as `~/.bashrc` or `~/.zshrc`, then
|
||||||
|
reload the shell.
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
---
|
||||||
|
title: Suffix Methods
|
||||||
|
---
|
||||||
|
|
||||||
|
# Suffix methods
|
||||||
|
|
||||||
|
`unique` works by appending a generated suffix to the original file or directory name. The suffix is
|
||||||
|
what makes the resulting name safe for repeated or automated use without collisions.
|
||||||
|
|
||||||
|
The exact suffix format depends on the method you choose. This lets you balance readability,
|
||||||
|
traceability, and compactness depending on the workload. The suffix method is selected per command
|
||||||
|
and can be changed to suit the naming requirements of the particular workflow.
|
||||||
|
|
||||||
|
If you do not pass `--method`, the default is `datetime`.
|
||||||
|
|
||||||
|
## Default behavior
|
||||||
|
|
||||||
|
```bash
|
||||||
|
unique create --file notes.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
This uses the `datetime` strategy by default and produces a name shaped like:
|
||||||
|
|
||||||
|
```text
|
||||||
|
notes-20260917-100923.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Available methods
|
||||||
|
|
||||||
|
### datetime
|
||||||
|
|
||||||
|
Use this when you want a human-readable timestamp and do not need a UUID-like identifier.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
unique create --file draft.txt --method datetime
|
||||||
|
unique create --dir build-output --method datetime
|
||||||
|
unique touch report.md --method datetime
|
||||||
|
unique duplicate archive.tar.gz --method datetime
|
||||||
|
```
|
||||||
|
|
||||||
|
Example result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
draft-20260917-100923.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
This method encodes the current date and time using the `YYYYMMdd-HHmmss` pattern. It is easy to
|
||||||
|
scan in logs and file listings, and it is the most readable option for regular local workflows.
|
||||||
|
|
||||||
|
### epoch
|
||||||
|
|
||||||
|
Use this when you want a numeric timestamp that is compact and easy to sort.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
unique create --file draft.txt --method epoch
|
||||||
|
```
|
||||||
|
|
||||||
|
Example result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
draft-1789667326956.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
This method uses the number of milliseconds since the Unix epoch. It is useful when a numeric suffix
|
||||||
|
is preferred for scripting, ordering, or easy correlation with timestamps in logs or automation.
|
||||||
|
|
||||||
|
### uuid
|
||||||
|
|
||||||
|
Use this when you need a strong, general-purpose unique identifier without caring about readability.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
unique create --file draft.txt --method uuid
|
||||||
|
```
|
||||||
|
|
||||||
|
Example result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
draft-f5bc2a13-6efa-43d1-b969-88e5ee3d67fa.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
This method creates a UUID v4 value and appends its canonical string form. It is a good choice when
|
||||||
|
uniqueness is the primary concern and the suffix does not need to be compact or human-friendly.
|
||||||
|
|
||||||
|
### uuid7
|
||||||
|
|
||||||
|
Use this when you want a UUID-based suffix that is both modern and sortable.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
unique create --file draft.txt --method uuid7
|
||||||
|
```
|
||||||
|
|
||||||
|
Example result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
draft-01a0b081-ceae-719a-8af8-4f298e64d896.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
UUID v7 incorporates time ordering, which helps when you want a unique name that also carries a rough
|
||||||
|
chronological signal. This is often a good fit for generated artifacts, logs, and content pipelines.
|
||||||
|
|
||||||
|
### uuid-b36
|
||||||
|
|
||||||
|
Use this when you want a shorter, more compact UUID-style suffix that still preserves uniqueness.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
unique create --file draft.txt --method uuid-b36
|
||||||
|
```
|
||||||
|
|
||||||
|
Example result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
draft-pg3oglhnrjcl-2f6i06345p9xi.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
This method starts from a UUID v4 value, splits it into 64-bit halves, and encodes the result in
|
||||||
|
base 36. The goal is shorter, more readable identifiers while retaining strong uniqueness.
|
||||||
|
|
||||||
|
### `uuid7-b36`
|
||||||
|
|
||||||
|
Use this when you want the same compactness as `uuid-b36` but with the sortability advantages of UUID v7.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
unique create --file draft.txt --method uuid7-b36
|
||||||
|
```
|
||||||
|
|
||||||
|
Example result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
draft-w2v0gvd69av-2g3zdzsjfpjmd.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
This is the compact, base-36 form of UUID v7. It is a strong option for generated asset names where
|
||||||
|
you want a short suffix without losing the time-oriented behavior of UUID v7.
|
||||||
|
|
||||||
|
## Choosing a method
|
||||||
|
|
||||||
|
A practical rule of thumb:
|
||||||
|
|
||||||
|
- `datetime`: best for human-readable output and quick inspection
|
||||||
|
- `epoch`: best for scripts and sortable numeric timestamps
|
||||||
|
- `uuid`: best for strong uniqueness with no readability concerns
|
||||||
|
- `uuid7`: best for modern UUID-based generation with chronological ordering
|
||||||
|
- `uuid-b36`: best when you want a shorter UUID-like suffix
|
||||||
|
- `uuid7-b36`: best when you want compactness plus UUID v7 semantics
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
`unique` does not promise a cryptographically special naming scheme for all methods; it is designed to
|
||||||
|
make collisions extremely unlikely in normal developer and automation workflows. The main tradeoff is
|
||||||
|
between readability and compactness, which is why several suffix strategies are exposed in the CLI.
|
||||||
+3
-3
@@ -26,7 +26,7 @@ options:
|
|||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Command: create
|
## create
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ./unique create -h
|
$ ./unique create -h
|
||||||
@@ -50,7 +50,7 @@ options:
|
|||||||
Default is 'datetime'.
|
Default is 'datetime'.
|
||||||
```
|
```
|
||||||
|
|
||||||
## Command: touch
|
## touch
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ./unique touch -h
|
$ ./unique touch -h
|
||||||
@@ -72,7 +72,7 @@ options:
|
|||||||
Default is 'datetime'.
|
Default is 'datetime'.
|
||||||
```
|
```
|
||||||
|
|
||||||
## Command: duplicate
|
## duplicate
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ./unique duplicate -h
|
$ ./unique duplicate -h
|
||||||
|
|||||||
Reference in New Issue
Block a user