docs: Added docs.

This commit is contained in:
2025-11-03 17:20:18 -05:00
parent d6ef585a45
commit 611ca6f820
13 changed files with 344 additions and 62 deletions

126
README.md
View File

@@ -3,7 +3,7 @@
Have you ever wanted to back up all your .env files in case your hard drive gets
nuked? `envr` makes it easier.
`envr` is a binary applicate that tracks your `.env` files
`envr` is a binary application that tracks your `.env` files
in an encyrpted sqlite database. Changes can be effortlessly synced with
`envr sync`, and restored with `envr restore`.
@@ -18,59 +18,57 @@ the tool [of your choosing](#backup-options).
be run on a cron.
- 🔍 **Smart Scanning**: Automatically discover and import `.env` files in your
home directory.
- 📝 **Multiple Config Formats**: Support for many configuration formats,
including: JSON, TOML, YAML, INI, XML, and NUON.
- [ ] TODO: 🗂️ **Rename Detection**: Automatically handle renamed repositories.
-**Interactive CLI**: User-friendly prompts for file selection and management
thanks to [nushell](https://www.nushell.sh/)
- **Interactive CLI**: User-friendly prompts for file selection and management.
## TODOS
- [ ] Allow configuration of ssh key.
- [ ] Allow multiple ssh keys.
- [ ] 🗂️ **Rename Detection**: Automatically handle renamed repositories.
- [ ] Allow use of keys from `ssh-agent`
- [x] Allow configuration of ssh key.
- [x] Allow multiple ssh keys.
## Prerequisites
- An SSH key pair (for encryption/decryption)
- The following binaries:
- [nushell](https://www.nushell.sh/)
- [age](https://github.com/FiloSottile/age)
- [fd](https://github.com/sharkdp/fd)
- [sqlite3](https://github.com/sqlite/sqlite)
- [git](https://git-scm.com)
## Installation
1. Clone the repository:
### With Go
If you already have `go` installed:
```bash
git clone https://github.com/username/envr.git
cd envr
go install github.com/sbrow/envr
envr init
```
### With Nix
If you are a [nix](https://nixos.org/) user
#### Try it out
```bash
nix run github.com:sbrow/envr --
```
#### Install it
```nix
# /etc/nixos/configuration.nix
{ config, envr, system, ... }: {
environment.systemPackages = [
envr.packages.${system}.default
];
}
```
2. Install [dependencies](#prerequisites).
3. Configure nushell.
## Quick Start
1. **Initialize envr**:
```bash
envr init
```
This will create your configuration file and set up encrypted storage.
2. **Scan for existing .env files**:
```bash
envr scan
```
Select files you want to back up from the interactive list.
3. **List tracked files**:
```bash
envr list
```
4. **Sync your environment files**:
```bash
envr sync
```
Check out the [man page](./docs/cli/envr.md) for the quick setup guide.
## Disclaimers
@@ -79,44 +77,52 @@ thanks to [nushell](https://www.nushell.sh/)
## Commands
| Command | Description |
|---------|-------------|
| `envr init [format]` | Initialize envr with configuration file |
| `envr backup <file>` | Back up a specific .env file |
| `envr restore [path]` | Restore a backed-up .env file |
| `envr list` | View all tracked environment files |
| `envr scan` | Search for and selectively back up .env files |
| `envr sync` | Synchronize all tracked files (backup changes, restore missing) |
| `envr remove [...paths]` | Remove files from backup storage |
| `envr edit config` | Edit your configuration file |
| `envr config show` | Display current configuration |
See [the docs](./docs/cli) for the current list of available commands.
## Configuration
The configuration file is created during initialization and supports multiple formats:
The configuration file is created during initialization:
```toml
# Example ~/.envr/config.toml
source = "~/.envr/config.toml"
priv_key = "~/.ssh/id_ed25519"
pub_key = "~/.ssh/id_ed25519.pub"
[scan]
matcher = "\.env"
exclude = "*.envrc"
include = "~"
```jsonc
# Example ~/.envr/config.json
{
"keys": [
{
"private": "/home/spencer/.ssh/id_ed25519",
"public": "/home/spencer/.ssh/id_ed25519.pub"
}
],
"scan": {
"matcher": "\\.env",
"exclude": "*.envrc",
"include": "~"
}
}
```
## Backup Options
`envr` merely gathers your `.env` files in one local place. It is up to you to
back up the database (found at ~/.envr/data.age) to a *secure* and *remote*
back up the database (found at `~/.envr/data.age`) to a *secure* and *remote*
location.
### Git
`envr` preserves inodes when updating the database, so you can safely hardlink
`~/.envr/data.age` into your [GNU Stow](https://www.gnu.org/software/stow/),
[Home Manager](https://github.com/nix-community/home-manager), or
[NixOS](https://nixos.wiki/wiki/flakes) repository.
> [!CAUTION]
> For **maximum security**, only save your `data.age` file to a local
(i.e. non-cloud) git server that **you personally control**.
>
> I take no responsibility if you push all your secrets to a public GitHub repo.
### restic
[restic](https://restic.readthedocs.io/en/latest/010_introduction.html).
## License
This project is licensed under the [MIT License](./LICENSE).

57
docs/cli/envr.md Normal file
View File

@@ -0,0 +1,57 @@
## envr
Manage your .env files.
### Synopsis
envr keeps your .env synced to a local, age encrypted database.
Is a safe and eay way to gather all your .env files in one place where they can
easily be backed by another tool such as restic or git.
All your data is stored in ~/data.age
Getting started is easy:
1. Create your configuration file and set up encrypted storage:
> envr init
2. Scan for existing .env files:
> envr scan
Select the files you want to back up from the interactive list.
3. Verify that it worked:
> envr list
4. After changing any of your .env files, update the backup with:
> envr sync
5. If you lose a repository, after re-cloning the repo into the same path it was
at before, restore your backup with:
> envr restore ~/&lt;path to repository&gt;/.env
### Options
```
-h, --help help for envr
```
### SEE ALSO
* [envr backup](envr_backup.md) - Import a .env file into envr
* [envr check](envr_check.md) - Check for missing binaries
* [envr edit-config](envr_edit-config.md) - Edit your config with your default editor
* [envr init](envr_init.md) - Set up envr
* [envr list](envr_list.md) - View your tracked files
* [envr nushell-completion](envr_nushell-completion.md) - Generate custom completions for nushell
* [envr remove](envr_remove.md) - Remove a .env file from your database
* [envr restore](envr_restore.md) - Install a .env file from the database into your file system
* [envr scan](envr_scan.md) - Find and select .env files for backup
* [envr sync](envr_sync.md) - Update or restore your env backups
* [envr version](envr_version.md) - Show envr's version

18
docs/cli/envr_backup.md Normal file
View File

@@ -0,0 +1,18 @@
## envr backup
Import a .env file into envr
```
envr backup <path> [flags]
```
### Options
```
-h, --help help for backup
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

24
docs/cli/envr_check.md Normal file
View File

@@ -0,0 +1,24 @@
## envr check
Check for missing binaries
### Synopsis
envr relies on external binaries for certain functionality.
The check command reports on which binaries are available and which are not.
```
envr check [flags]
```
### Options
```
-h, --help help for check
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

View File

@@ -0,0 +1,18 @@
## envr edit-config
Edit your config with your default editor
```
envr edit-config [flags]
```
### Options
```
-h, --help help for edit-config
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

27
docs/cli/envr_init.md Normal file
View File

@@ -0,0 +1,27 @@
## envr init
Set up envr
### Synopsis
The init command generates your initial config and saves it to
~/.envr/config in JSON format.
During setup, you will be prompted to select one or more ssh keys with which to
encrypt your databse. **Make 100% sure** that you have **a remote copy** of this
key somewhere, otherwise your data could be lost forever.
```
envr init
```
### Options
```
-h, --help help for init
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

18
docs/cli/envr_list.md Normal file
View File

@@ -0,0 +1,18 @@
## envr list
View your tracked files
```
envr list [flags]
```
### Options
```
-h, --help help for list
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

View File

@@ -0,0 +1,23 @@
## envr nushell-completion
Generate custom completions for nushell
### Synopsis
At time of writing, cobra does not natively support nushell,
so a custom command had to be written
```
envr nushell-completion [flags]
```
### Options
```
-h, --help help for nushell-completion
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

18
docs/cli/envr_remove.md Normal file
View File

@@ -0,0 +1,18 @@
## envr remove
Remove a .env file from your database
```
envr remove [flags]
```
### Options
```
-h, --help help for remove
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

18
docs/cli/envr_restore.md Normal file
View File

@@ -0,0 +1,18 @@
## envr restore
Install a .env file from the database into your file system
```
envr restore [flags]
```
### Options
```
-h, --help help for restore
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

18
docs/cli/envr_scan.md Normal file
View File

@@ -0,0 +1,18 @@
## envr scan
Find and select .env files for backup
```
envr scan [flags]
```
### Options
```
-h, --help help for scan
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

18
docs/cli/envr_sync.md Normal file
View File

@@ -0,0 +1,18 @@
## envr sync
Update or restore your env backups
```
envr sync [flags]
```
### Options
```
-h, --help help for sync
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.

19
docs/cli/envr_version.md Normal file
View File

@@ -0,0 +1,19 @@
## envr version
Show envr's version
```
envr version [flags]
```
### Options
```
-h, --help help for version
-l, --long Show all version information
```
### SEE ALSO
* [envr](envr.md) - Manage your .env files.