Compare commits

...

3 commits

Author SHA1 Message Date
Lilian Jónsdóttir 5e90d8f138 version bump - v0.2.1 2024-04-03 17:17:13 -07:00
Lilian Jónsdóttir 13e91157da less verbose error 2024-04-03 17:15:32 -07:00
Lilian Jónsdóttir b18ea5ff7b error if empty editor 2024-04-03 17:15:32 -07:00
2 changed files with 7 additions and 2 deletions

View file

@ -22,7 +22,7 @@ import (
const ( const (
name string = "agedit" name string = "agedit"
usage string = "Edit age encrypted files with your $EDITOR" usage string = "Edit age encrypted files with your $EDITOR"
version string = "0.2.0" version string = "0.2.1"
help_template string = `NAME: help_template string = `NAME:
{{.Name}} {{if .Version}}v{{.Version}}{{end}} - {{.Usage}} {{.Name}} {{if .Version}}v{{.Version}}{{end}} - {{.Usage}}
@ -210,7 +210,7 @@ func action(ctx *cli.Context) error {
// read from identity file if exists and no identities have been supplied // read from identity file if exists and no identities have been supplied
if !gave_identities { if !gave_identities {
if _, err := os.Stat(cfg.IdentityFile); os.IsNotExist(err) { if _, err := os.Stat(cfg.IdentityFile); os.IsNotExist(err) {
return fmt.Errorf("identity file unset and no identities supplied, use -i to specify an idenitity file or set one in the config file, or use -I to specify an age private key") return fmt.Errorf("identity file unset and no identities supplied")
} else { } else {
f, err := os.Open(cfg.IdentityFile) f, err := os.Open(cfg.IdentityFile)
if err != nil { if err != nil {

View file

@ -1,6 +1,7 @@
package editor package editor
import ( import (
"fmt"
"io/fs" "io/fs"
"os" "os"
"os/exec" "os/exec"
@ -18,6 +19,10 @@ type Editor struct {
func (e *Editor) EditFile(filename string) error { func (e *Editor) EditFile(filename string) error {
args := append(e.Args, filename) args := append(e.Args, filename)
if e.Command == "" {
return fmt.Errorf("no editor set or detected")
}
cmd := exec.Command(e.Command, args...) cmd := exec.Command(e.Command, args...)
cmd.Stdin = os.Stdin cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout