Skip to content

Commit 611ca6f

Browse files
author
Spencer Brower
committed
docs: Added docs.
1 parent d6ef585 commit 611ca6f

File tree

13 files changed

+343
-61
lines changed

13 files changed

+343
-61
lines changed

README.md

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Have you ever wanted to back up all your .env files in case your hard drive gets
44
nuked? `envr` makes it easier.
55

6-
`envr` is a binary applicate that tracks your `.env` files
6+
`envr` is a binary application that tracks your `.env` files
77
in an encyrpted sqlite database. Changes can be effortlessly synced with
88
`envr sync`, and restored with `envr restore`.
99

@@ -18,59 +18,57 @@ the tool [of your choosing](#backup-options).
1818
be run on a cron.
1919
- 🔍 **Smart Scanning**: Automatically discover and import `.env` files in your
2020
home directory.
21-
- 📝 **Multiple Config Formats**: Support for many configuration formats,
22-
including: JSON, TOML, YAML, INI, XML, and NUON.
23-
- [ ] TODO: 🗂️ **Rename Detection**: Automatically handle renamed repositories.
24-
-**Interactive CLI**: User-friendly prompts for file selection and management
25-
thanks to [nushell](https://www.nushell.sh/)
21+
-**Interactive CLI**: User-friendly prompts for file selection and management.
2622

2723
## TODOS
2824

29-
- [ ] Allow configuration of ssh key.
30-
- [ ] Allow multiple ssh keys.
25+
- [ ] 🗂️ **Rename Detection**: Automatically handle renamed repositories.
26+
- [ ] Allow use of keys from `ssh-agent`
27+
- [x] Allow configuration of ssh key.
28+
- [x] Allow multiple ssh keys.
3129

3230
## Prerequisites
3331

3432
- An SSH key pair (for encryption/decryption)
3533
- The following binaries:
36-
- [nushell](https://www.nushell.sh/)
37-
- [age](https://github.com/FiloSottile/age)
3834
- [fd](https://github.com/sharkdp/fd)
39-
- [sqlite3](https://github.com/sqlite/sqlite)
35+
- [git](https://git-scm.com)
4036

4137
## Installation
4238

43-
1. Clone the repository:
44-
```bash
45-
git clone https://github.com/username/envr.git
46-
cd envr
47-
```
48-
2. Install [dependencies](#prerequisites).
49-
3. Configure nushell.
39+
### With Go
5040

51-
## Quick Start
41+
If you already have `go` installed:
42+
43+
```bash
44+
go install github.com/sbrow/envr
45+
envr init
46+
```
47+
48+
### With Nix
49+
50+
If you are a [nix](https://nixos.org/) user
51+
52+
#### Try it out
53+
54+
```bash
55+
nix run github.com:sbrow/envr --
56+
```
5257

53-
1. **Initialize envr**:
54-
```bash
55-
envr init
56-
```
57-
This will create your configuration file and set up encrypted storage.
58+
#### Install it
5859

59-
2. **Scan for existing .env files**:
60-
```bash
61-
envr scan
62-
```
63-
Select files you want to back up from the interactive list.
60+
```nix
61+
# /etc/nixos/configuration.nix
62+
{ config, envr, system, ... }: {
63+
environment.systemPackages = [
64+
envr.packages.${system}.default
65+
];
66+
}
67+
```
6468

65-
3. **List tracked files**:
66-
```bash
67-
envr list
68-
```
69+
## Quick Start
6970

70-
4. **Sync your environment files**:
71-
```bash
72-
envr sync
73-
```
71+
Check out the [man page](./docs/cli/envr.md) for the quick setup guide.
7472

7573
## Disclaimers
7674

@@ -79,44 +77,52 @@ thanks to [nushell](https://www.nushell.sh/)
7977
8078
## Commands
8179

82-
| Command | Description |
83-
|---------|-------------|
84-
| `envr init [format]` | Initialize envr with configuration file |
85-
| `envr backup <file>` | Back up a specific .env file |
86-
| `envr restore [path]` | Restore a backed-up .env file |
87-
| `envr list` | View all tracked environment files |
88-
| `envr scan` | Search for and selectively back up .env files |
89-
| `envr sync` | Synchronize all tracked files (backup changes, restore missing) |
90-
| `envr remove [...paths]` | Remove files from backup storage |
91-
| `envr edit config` | Edit your configuration file |
92-
| `envr config show` | Display current configuration |
80+
See [the docs](./docs/cli) for the current list of available commands.
9381

9482
## Configuration
9583

96-
The configuration file is created during initialization and supports multiple formats:
97-
98-
```toml
99-
# Example ~/.envr/config.toml
100-
source = "~/.envr/config.toml"
101-
priv_key = "~/.ssh/id_ed25519"
102-
pub_key = "~/.ssh/id_ed25519.pub"
103-
104-
[scan]
105-
matcher = "\.env"
106-
exclude = "*.envrc"
107-
include = "~"
84+
The configuration file is created during initialization:
85+
86+
```jsonc
87+
# Example ~/.envr/config.json
88+
{
89+
"keys": [
90+
{
91+
"private": "/home/spencer/.ssh/id_ed25519",
92+
"public": "/home/spencer/.ssh/id_ed25519.pub"
93+
}
94+
],
95+
"scan": {
96+
"matcher": "\\.env",
97+
"exclude": "*.envrc",
98+
"include": "~"
99+
}
100+
}
108101
```
109102

110103
## Backup Options
111104

112105
`envr` merely gathers your `.env` files in one local place. It is up to you to
113-
back up the database (found at ~/.envr/data.age) to a *secure* and *remote*
106+
back up the database (found at `~/.envr/data.age`) to a *secure* and *remote*
114107
location.
115108

116109
### Git
117110

111+
`envr` preserves inodes when updating the database, so you can safely hardlink
112+
`~/.envr/data.age` into your [GNU Stow](https://www.gnu.org/software/stow/),
113+
[Home Manager](https://github.com/nix-community/home-manager), or
114+
[NixOS](https://nixos.wiki/wiki/flakes) repository.
115+
116+
> [!CAUTION]
117+
> For **maximum security**, only save your `data.age` file to a local
118+
(i.e. non-cloud) git server that **you personally control**.
119+
>
120+
> I take no responsibility if you push all your secrets to a public GitHub repo.
121+
118122
### restic
119123

124+
[restic](https://restic.readthedocs.io/en/latest/010_introduction.html).
125+
120126
## License
121127

122128
This project is licensed under the [MIT License](./LICENSE).

docs/cli/envr.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## envr
2+
3+
Manage your .env files.
4+
5+
### Synopsis
6+
7+
envr keeps your .env synced to a local, age encrypted database.
8+
Is a safe and eay way to gather all your .env files in one place where they can
9+
easily be backed by another tool such as restic or git.
10+
11+
All your data is stored in ~/data.age
12+
13+
Getting started is easy:
14+
15+
1. Create your configuration file and set up encrypted storage:
16+
17+
> envr init
18+
19+
2. Scan for existing .env files:
20+
21+
> envr scan
22+
23+
Select the files you want to back up from the interactive list.
24+
25+
3. Verify that it worked:
26+
27+
> envr list
28+
29+
4. After changing any of your .env files, update the backup with:
30+
31+
> envr sync
32+
33+
5. If you lose a repository, after re-cloning the repo into the same path it was
34+
at before, restore your backup with:
35+
36+
> envr restore ~/&lt;path to repository&gt;/.env
37+
38+
### Options
39+
40+
```
41+
-h, --help help for envr
42+
```
43+
44+
### SEE ALSO
45+
46+
* [envr backup](envr_backup.md) - Import a .env file into envr
47+
* [envr check](envr_check.md) - Check for missing binaries
48+
* [envr edit-config](envr_edit-config.md) - Edit your config with your default editor
49+
* [envr init](envr_init.md) - Set up envr
50+
* [envr list](envr_list.md) - View your tracked files
51+
* [envr nushell-completion](envr_nushell-completion.md) - Generate custom completions for nushell
52+
* [envr remove](envr_remove.md) - Remove a .env file from your database
53+
* [envr restore](envr_restore.md) - Install a .env file from the database into your file system
54+
* [envr scan](envr_scan.md) - Find and select .env files for backup
55+
* [envr sync](envr_sync.md) - Update or restore your env backups
56+
* [envr version](envr_version.md) - Show envr's version
57+

docs/cli/envr_backup.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## envr backup
2+
3+
Import a .env file into envr
4+
5+
```
6+
envr backup <path> [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-h, --help help for backup
13+
```
14+
15+
### SEE ALSO
16+
17+
* [envr](envr.md) - Manage your .env files.
18+

docs/cli/envr_check.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## envr check
2+
3+
Check for missing binaries
4+
5+
### Synopsis
6+
7+
envr relies on external binaries for certain functionality.
8+
9+
The check command reports on which binaries are available and which are not.
10+
11+
```
12+
envr check [flags]
13+
```
14+
15+
### Options
16+
17+
```
18+
-h, --help help for check
19+
```
20+
21+
### SEE ALSO
22+
23+
* [envr](envr.md) - Manage your .env files.
24+

docs/cli/envr_edit-config.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## envr edit-config
2+
3+
Edit your config with your default editor
4+
5+
```
6+
envr edit-config [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-h, --help help for edit-config
13+
```
14+
15+
### SEE ALSO
16+
17+
* [envr](envr.md) - Manage your .env files.
18+

docs/cli/envr_init.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## envr init
2+
3+
Set up envr
4+
5+
### Synopsis
6+
7+
The init command generates your initial config and saves it to
8+
~/.envr/config in JSON format.
9+
10+
During setup, you will be prompted to select one or more ssh keys with which to
11+
encrypt your databse. **Make 100% sure** that you have **a remote copy** of this
12+
key somewhere, otherwise your data could be lost forever.
13+
14+
```
15+
envr init
16+
```
17+
18+
### Options
19+
20+
```
21+
-h, --help help for init
22+
```
23+
24+
### SEE ALSO
25+
26+
* [envr](envr.md) - Manage your .env files.
27+

docs/cli/envr_list.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## envr list
2+
3+
View your tracked files
4+
5+
```
6+
envr list [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-h, --help help for list
13+
```
14+
15+
### SEE ALSO
16+
17+
* [envr](envr.md) - Manage your .env files.
18+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## envr nushell-completion
2+
3+
Generate custom completions for nushell
4+
5+
### Synopsis
6+
7+
At time of writing, cobra does not natively support nushell,
8+
so a custom command had to be written
9+
10+
```
11+
envr nushell-completion [flags]
12+
```
13+
14+
### Options
15+
16+
```
17+
-h, --help help for nushell-completion
18+
```
19+
20+
### SEE ALSO
21+
22+
* [envr](envr.md) - Manage your .env files.
23+

docs/cli/envr_remove.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## envr remove
2+
3+
Remove a .env file from your database
4+
5+
```
6+
envr remove [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-h, --help help for remove
13+
```
14+
15+
### SEE ALSO
16+
17+
* [envr](envr.md) - Manage your .env files.
18+

0 commit comments

Comments
 (0)