Compare commits

..

No commits in common. "5a96e7969444ee0f812e85e408914fb8102e8915" and "6aa7aca85e3be116dc75e941f616399d9bc2dc1c" have entirely different histories.

6 changed files with 9 additions and 17 deletions

View file

@ -1,6 +1,6 @@
# agedit # agedit
open an [age](https://github.com/FiloSottile/age) encrypted file in $EDITOR open an age encrypted file in $EDITOR
## cli ## cli
`go install git.burning.moe/celediel/agedit/cmd/agedit@latest` `go install git.burning.moe/celediel/agedit/cmd/agedit@latest`

View file

@ -19,7 +19,7 @@ import (
const ( const (
name = "agedit" name = "agedit"
usage = "Edit age encrypted files with your $EDITOR" usage = "Edit age encrypted files with your $EDITOR"
version = "0.0.2" version = "0.0.1"
help_template = `NAME: help_template = `NAME:
{{.Name}} {{if .Version}}v{{.Version}}{{end}} - {{.Usage}} {{.Name}} {{if .Version}}v{{.Version}}{{end}} - {{.Usage}}
@ -115,7 +115,7 @@ func before(ctx *cli.Context) error {
// load config from file // load config from file
_, err := os.Open(configFile) _, err := os.Open(configFile)
if err != nil && errors.Is(err, os.ErrNotExist) { if err != nil && !errors.Is(err, os.ErrNotExist) {
// or not // or not
logger.Debug("couldn't load config file", "file", configFile) logger.Debug("couldn't load config file", "file", configFile)
} else { } else {

2
go.mod
View file

@ -1,6 +1,6 @@
module git.burning.moe/celediel/agedit module git.burning.moe/celediel/agedit
go 1.21.0 go 1.22.0
require ( require (
filippo.io/age v1.1.1 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. // TestNewIdentity creats a new identity, writes it to file, then re-reads it back from the file.
func TestNewIdentity(t *testing.T) { func TestNewIdentity(t *testing.T) {
for i := 0; i <= 1000; i++ { for range 1000 {
outfile := generator.GenerateFullPath() outfile := generator.GenerateFullPath()
identity, err := NewIdentity() identity, err := NewIdentity()

12
pkg/env/env.go vendored
View file

@ -78,24 +78,16 @@ func GetDataDir(appname string) string {
// //
// returns %TEMP% on Windows, /tmp on UNIX-like systems // returns %TEMP% on Windows, /tmp on UNIX-like systems
func GetTempDirectory() string { func GetTempDirectory() string {
var tmp string
switch runtime.GOOS { switch runtime.GOOS {
case "windows": case "windows":
tmp = os.Getenv("TEMP") return os.Getenv("TEMP")
case "android":
if t := os.Getenv("TMPDIR"); t != "" {
tmp = t
} else if t = os.Getenv("PREFIX"); t != "" {
tmp = t + "/tmp"
}
default: default:
fallthrough fallthrough
case "darwin": case "darwin":
fallthrough fallthrough
case "linux": case "linux":
tmp = "/tmp" return "/tmp"
} }
return tmp
} }
func make_path(paths ...string) string { func make_path(paths ...string) string {

View file

@ -12,7 +12,7 @@ var generator = NewGenerator("test_", ".txt", 18)
func TestCanCreateTmpFile(t *testing.T) { func TestCanCreateTmpFile(t *testing.T) {
b := []byte{104, 101, 108, 108, 111, 32, 116, 104, 101, 114, 101} b := []byte{104, 101, 108, 108, 111, 32, 116, 104, 101, 114, 101}
for i := 0; i <= 1000; i++ { for range 1000 {
outfile := generator.GenerateFullPath() outfile := generator.GenerateFullPath()
err := os.WriteFile(outfile, b, fs.FileMode(0600)) err := os.WriteFile(outfile, b, fs.FileMode(0600))
if err != nil { if err != nil {
@ -33,7 +33,7 @@ func TestCanCreateTmpFile(t *testing.T) {
func TestUniqueTmpFile(t *testing.T) { func TestUniqueTmpFile(t *testing.T) {
var generated_names = map[string]string{} var generated_names = map[string]string{}
for i := 0; i <= 100000; i++ { for range 100000 {
name := generator.GenerateName() name := generator.GenerateName()
if val, ok := generated_names[name]; ok { if val, ok := generated_names[name]; ok {
t.Fatal("Non unique name", val) t.Fatal("Non unique name", val)