mirror of
https://github.com/sbrow/envr.git
synced 2025-12-29 15:47:38 -05:00
feat: Implemented sync command.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
## TODOS
|
||||
|
||||
- [ ] `envr sync` - Restore missing .env files, and update backed up ones.
|
||||
- [x] `envr sync` - Restore missing .env files, and update backed up ones.
|
||||
- [x] `envr scan` - Search for missing / moved .env files.
|
||||
|
||||
17
mod.nu
17
mod.nu
@@ -177,7 +177,6 @@ export def "envr init" [
|
||||
source: $source
|
||||
priv_key: $identity
|
||||
pub_key: $'($identity).pub'
|
||||
# TODO: scan settings
|
||||
scan: {
|
||||
matcher: '\.env'
|
||||
exclude: '*.envrc'
|
||||
@@ -209,17 +208,21 @@ def files [] {
|
||||
)
|
||||
}
|
||||
|
||||
# Update your env backups
|
||||
# Update or restore your env backups
|
||||
export def "envr sync" [] {
|
||||
let $files = (files);
|
||||
|
||||
$files | each { |it|
|
||||
# TODO: Check for file existence
|
||||
# TODO: If file exists and sha changed: `envr backup $it.path`
|
||||
# TODO: If file doesn't exist: `envr restore $it.path`
|
||||
if ($it.path | path type | $in == 'file') {
|
||||
if (open $it.path | hash sha256 | $in != $it.sha256) {
|
||||
envr backup $it.path
|
||||
} else {
|
||||
'Nothing to do!'
|
||||
}
|
||||
} else {
|
||||
envr restore $it.path
|
||||
}
|
||||
}
|
||||
|
||||
'TODO: Need to implement'
|
||||
}
|
||||
|
||||
# Search for .env files and select ones to back up.
|
||||
|
||||
Reference in New Issue
Block a user