aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-08-23 21:36:23 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-27 18:44:12 +0200
commita5bc7ccf0cae608ac1e72ab4c9ebe5596eb8c988 (patch)
treebe2e5f55fc21980489dca61947ea6b9819853ec3 /commands
parentfff16640ad7cd8c4b73187fbce10f2aa558701be (diff)
downloadaerc-a5bc7ccf0cae608ac1e72ab4c9ebe5596eb8c988.tar.gz
xdg: get rid of deprecated dependencies
github.com/mitchellh/go-homedir has not received any update since 2019. The last release of github.com/kyoh86/xdg was in 2020 and it has been marked as deprecated by its author. Replace these with internal functions. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'commands')
-rw-r--r--commands/cd.go7
-rw-r--r--commands/compose/attach.go10
-rw-r--r--commands/history.go7
-rw-r--r--commands/msgview/save.go10
-rw-r--r--commands/util.go9
5 files changed, 12 insertions, 31 deletions
diff --git a/commands/cd.go b/commands/cd.go
index dc05adbb..8c0191c2 100644
--- a/commands/cd.go
+++ b/commands/cd.go
@@ -5,8 +5,8 @@ import (
"os"
"strings"
+ "git.sr.ht/~rjarry/aerc/lib/xdg"
"git.sr.ht/~rjarry/aerc/widgets"
- "github.com/mitchellh/go-homedir"
)
var previousDir string
@@ -54,10 +54,7 @@ func (ChangeDirectory) Execute(aerc *widgets.Aerc, args []string) error {
target = previousDir
}
}
- target, err = homedir.Expand(target)
- if err != nil {
- return err
- }
+ target = xdg.ExpandHome(target)
if err := os.Chdir(target); err == nil {
previousDir = cwd
aerc.UpdateStatus()
diff --git a/commands/compose/attach.go b/commands/compose/attach.go
index 3f6d124f..f9ef027f 100644
--- a/commands/compose/attach.go
+++ b/commands/compose/attach.go
@@ -14,9 +14,9 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/ui"
+ "git.sr.ht/~rjarry/aerc/lib/xdg"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
- "github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"git.sr.ht/~sircmpwn/getopt"
@@ -83,13 +83,7 @@ func (a Attach) Execute(aerc *widgets.Aerc, args []string) error {
}
func (a Attach) addPath(aerc *widgets.Aerc, path string) error {
- path, err := homedir.Expand(path)
- if err != nil {
- log.Errorf("failed to expand path '%s': %v", path, err)
- aerc.PushError(err.Error())
- return err
- }
-
+ path = xdg.ExpandHome(path)
attachments, err := filepath.Glob(path)
if err != nil && errors.Is(err, filepath.ErrBadPattern) {
log.Warnf("failed to parse as globbing pattern: %v", err)
diff --git a/commands/history.go b/commands/history.go
index 7aa42fab..cc85f3ba 100644
--- a/commands/history.go
+++ b/commands/history.go
@@ -6,11 +6,10 @@ import (
"fmt"
"io"
"os"
- "path"
"sync"
+ "git.sr.ht/~rjarry/aerc/lib/xdg"
"git.sr.ht/~rjarry/aerc/log"
- "github.com/kyoh86/xdg"
)
type cmdHistory struct {
@@ -92,9 +91,9 @@ func (h *cmdHistory) initialize() {
var err error
openFlags := os.O_RDWR | os.O_EXCL
- histPath := path.Join(xdg.CacheHome(), "aerc", "history")
+ histPath := xdg.CachePath("aerc", "history")
if _, err := os.Stat(histPath); os.IsNotExist(err) {
- _ = os.MkdirAll(path.Join(xdg.CacheHome(), "aerc"), 0o700) // caught by OpenFile
+ _ = os.MkdirAll(xdg.CachePath("aerc"), 0o700) // caught by OpenFile
openFlags |= os.O_CREATE
}
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 170ef7c1..1ffdaf92 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -10,10 +10,10 @@ import (
"time"
"git.sr.ht/~sircmpwn/getopt"
- "github.com/mitchellh/go-homedir"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/config"
+ "git.sr.ht/~rjarry/aerc/lib/xdg"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -40,8 +40,7 @@ func (s Save) Complete(aerc *widgets.Aerc, args []string) []string {
if defaultPath != "" && !isAbsPath(path) {
path = filepath.Join(defaultPath, path)
}
- path, _ = homedir.Expand(path)
- return commands.CompletePath(path)
+ return commands.CompletePath(xdg.ExpandHome(path))
}
type saveParams struct {
@@ -99,10 +98,7 @@ func (s Save) Execute(aerc *widgets.Aerc, args []string) error {
path = filepath.Join(defaultPath, path)
}
- path, err = homedir.Expand(path)
- if err != nil {
- return err
- }
+ path = xdg.ExpandHome(path)
mv, ok := aerc.SelectedTabContent().(*widgets.MessageViewer)
if !ok {
diff --git a/commands/util.go b/commands/util.go
index 7e21e167..aeb18237 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -13,12 +13,12 @@ import (
"github.com/lithammer/fuzzysearch/fuzzy"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/lib/xdg"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
"github.com/gdamore/tcell/v2"
- "github.com/mitchellh/go-homedir"
)
// QuickTerm is an ephemeral terminal for running a single command and quitting.
@@ -80,13 +80,8 @@ func CompletePath(path string) []string {
path = cwd
}
- path, err := homedir.Expand(path)
- if err != nil {
- return nil
- }
-
// strip trailing slashes, etc.
- path = filepath.Clean(path)
+ path = filepath.Clean(xdg.ExpandHome(path))
if _, err := os.Stat(path); os.IsNotExist(err) {
// if the path doesn't exist, it is likely due to it being a partial path