updated project documentation
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user