Compare commits
5 commits
6aa7aca85e
...
5a96e79694
Author | SHA1 | Date | |
---|---|---|---|
Lilian Jónsdóttir | 5a96e79694 | ||
Lilian Jónsdóttir | 80dff639a1 | ||
Lilian Jónsdóttir | e6711c65fc | ||
Lilian Jónsdóttir | d1f173cab3 | ||
Lilian Jónsdóttir | eefc0340db |
|
@ -1,6 +1,6 @@
|
|||
# agedit
|
||||
|
||||
open an age encrypted file in $EDITOR
|
||||
open an [age](https://github.com/FiloSottile/age) encrypted file in $EDITOR
|
||||
|
||||
## cli
|
||||
`go install git.burning.moe/celediel/agedit/cmd/agedit@latest`
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
const (
|
||||
name = "agedit"
|
||||
usage = "Edit age encrypted files with your $EDITOR"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
help_template = `NAME:
|
||||
{{.Name}} {{if .Version}}v{{.Version}}{{end}} - {{.Usage}}
|
||||
|
||||
|
@ -115,7 +115,7 @@ func before(ctx *cli.Context) error {
|
|||
|
||||
// load config from file
|
||||
_, err := os.Open(configFile)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
if err != nil && errors.Is(err, os.ErrNotExist) {
|
||||
// or not
|
||||
logger.Debug("couldn't load config file", "file", configFile)
|
||||
} else {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module git.burning.moe/celediel/agedit
|
||||
|
||||
go 1.22.0
|
||||
go 1.21.0
|
||||
|
||||
require (
|
||||
filippo.io/age v1.1.1
|
||||
|
|
|
@ -75,7 +75,7 @@ func TestEncryptionDecryption(t *testing.T) {
|
|||
|
||||
// TestNewIdentity creats a new identity, writes it to file, then re-reads it back from the file.
|
||||
func TestNewIdentity(t *testing.T) {
|
||||
for range 1000 {
|
||||
for i := 0; i <= 1000; i++ {
|
||||
outfile := generator.GenerateFullPath()
|
||||
|
||||
identity, err := NewIdentity()
|
||||
|
|
12
pkg/env/env.go
vendored
12
pkg/env/env.go
vendored
|
@ -78,16 +78,24 @@ func GetDataDir(appname string) string {
|
|||
//
|
||||
// returns %TEMP% on Windows, /tmp on UNIX-like systems
|
||||
func GetTempDirectory() string {
|
||||
var tmp string
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return os.Getenv("TEMP")
|
||||
tmp = os.Getenv("TEMP")
|
||||
case "android":
|
||||
if t := os.Getenv("TMPDIR"); t != "" {
|
||||
tmp = t
|
||||
} else if t = os.Getenv("PREFIX"); t != "" {
|
||||
tmp = t + "/tmp"
|
||||
}
|
||||
default:
|
||||
fallthrough
|
||||
case "darwin":
|
||||
fallthrough
|
||||
case "linux":
|
||||
return "/tmp"
|
||||
tmp = "/tmp"
|
||||
}
|
||||
return tmp
|
||||
}
|
||||
|
||||
func make_path(paths ...string) string {
|
||||
|
|
|
@ -12,7 +12,7 @@ var generator = NewGenerator("test_", ".txt", 18)
|
|||
func TestCanCreateTmpFile(t *testing.T) {
|
||||
b := []byte{104, 101, 108, 108, 111, 32, 116, 104, 101, 114, 101}
|
||||
|
||||
for range 1000 {
|
||||
for i := 0; i <= 1000; i++ {
|
||||
outfile := generator.GenerateFullPath()
|
||||
err := os.WriteFile(outfile, b, fs.FileMode(0600))
|
||||
if err != nil {
|
||||
|
@ -33,7 +33,7 @@ func TestCanCreateTmpFile(t *testing.T) {
|
|||
func TestUniqueTmpFile(t *testing.T) {
|
||||
var generated_names = map[string]string{}
|
||||
|
||||
for range 100000 {
|
||||
for i := 0; i <= 100000; i++ {
|
||||
name := generator.GenerateName()
|
||||
if val, ok := generated_names[name]; ok {
|
||||
t.Fatal("Non unique name", val)
|
||||
|
|
Loading…
Reference in a new issue