Compare commits

...

5 commits

Author SHA1 Message Date
Lilian Jónsdóttir 5a96e79694 fix bug = bump version 2024-03-14 09:58:18 -07:00
Lilian Jónsdóttir 80dff639a1 fix dumb mistake
turns out I'm dumb
2024-03-14 09:54:12 -07:00
Lilian Jónsdóttir e6711c65fc update readme 2024-03-14 09:47:54 -07:00
Lilian Jónsdóttir d1f173cab3 support for android via termux
I have no idea if it's possible (or even worth it) to get go running in the adb shell
android has no /tmp so I wouldn't know where to store files outside of termux
2024-03-14 09:47:19 -07:00
Lilian Jónsdóttir eefc0340db fallback to go pre go1.22 syntax 2024-03-14 09:45:01 -07:00
6 changed files with 17 additions and 9 deletions

View file

@ -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`

View file

@ -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
View file

@ -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

View file

@ -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
View file

@ -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 {

View file

@ -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)