~emersion/hut-dev

hut init: early check if config already exists v2 APPLIED

Jackson Chen: 1
 hut init: early check if config already exists

 1 files changed, 8 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/hut-dev/patches/44875/mbox | git am -3
Learn more about email & git

[PATCH v2] hut init: early check if config already exists Export this patch

The check is placed before the token is requested, so the request for
token isn't useless.
---
Previously "hut init: move file/folder opening earlier"

 config.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/config.go b/config.go
index 51023ac..d7270b5 100644
--- a/config.go
+++ b/config.go
@@ -170,6 +170,14 @@ func newInitCommand() *cobra.Command {
			filename = defaultConfigFilename()
		}

		configFileStat, err := os.Stat(filename)
		if configFileStat != nil {
			log.Fatalf("config file %q already exists (delete it if you want to overwrite it)", filename)
		}
		if err != nil && !errors.Is(err, os.ErrNotExist) {
			log.Fatal(err)
		}

		instance, err := cmd.Flags().GetString("instance")
		if err != nil {
			log.Fatal(err)
-- 
2.42.0
Pushed, thanks!