]> 91.132.146.200 Git - scientia.git/commitdiff
changed to github.com/adrg/xdg
authorBanana <mail@bananas-playground.net>
Sat, 20 Jul 2024 10:07:48 +0000 (12:07 +0200)
committerBanana <mail@bananas-playground.net>
Sat, 20 Jul 2024 10:07:48 +0000 (12:07 +0200)
Signed-off-by: Banana <mail@bananas-playground.net>
client/go-cli/scientia/cmd/config_init.go
client/go-cli/scientia/cmd/root.go
client/go-cli/scientia/go.mod
client/go-cli/scientia/go.sum
documentation/structure-main.d2 [new file with mode: 0644]
documentation/structure.d2 [deleted file]

index 43cceb9a7b73c4955adaa6928aa95635fbd42824..f538e4aa31e45ec4ba96c243ed9131addeed33f1 100644 (file)
@@ -3,7 +3,6 @@ package cmd
 import (
        "errors"
        "fmt"
-       "github.com/kirsle/configdir"
        "github.com/spf13/cobra"
        "os"
        Helper "scientia/lib"
@@ -43,12 +42,14 @@ var configInitCmd = &cobra.Command {
 
 // initConfig which creates the default config file
 func initConfig() {
-       err := configdir.MakePath(ScientiaConfigPath) // Ensure it exists.
-       Helper.ErrorCheck(err, "No $HOME/.config/scientia directory available?")
+       if _, err := os.Stat(ScientiaConfigPath); os.IsNotExist(err) {
+               err := os.MkdirAll(ScientiaConfigPath, os.ModePerm);
+               Helper.ErrorCheck(err, "No $HOME/.config/scientia directory available?")
+       }
 
        if FlagDebug {
                fmt.Printf("DEBUG Local user config path: %s\n", ScientiaConfigPath)
-               fmt.Printf("DEBUG Local user config file: %s\n", ScientiaConfigPath)
+               fmt.Printf("DEBUG Local user config file: %s\n", ScientiaConfigFile)
        }
 
        if _, err := os.Stat(ScientiaConfigFile); errors.Is(err, os.ErrNotExist) {
index a1738f89c1a77be988e2f54743c3866381b71dc0..b2b6260e4487580cf8aefe1a019648b20b607882 100644 (file)
@@ -3,7 +3,7 @@ package cmd
 import (
        "errors"
        "fmt"
-       "github.com/kirsle/configdir"
+       "github.com/adrg/xdg"
        "github.com/spf13/cobra"
        "gopkg.in/yaml.v3"
        "log"
@@ -28,8 +28,8 @@ type ConfigStruct struct {
 // The ScientiaConfig used globally
 var ScientiaConfig ConfigStruct
 
-var ScientiaConfigPath = configdir.LocalConfig("scientia")
-var ScientiaConfigFile = ScientiaConfigPath + "/.scientia.yaml"
+var ScientiaConfigPath = xdg.ConfigHome + "/scientia"
+var ScientiaConfigFile = ScientiaConfigPath + "/scientia.yaml"
 
 // The rootCmd
 var rootCmd = &cobra.Command{
index 2e863b52e14284ac634cb7ffa85ac0ebf4e6161c..cbecda6674d07cf3a8082d6dfb3b86b2696882da 100644 (file)
@@ -10,11 +10,12 @@ require (
 )
 
 require (
+       github.com/adrg/xdg v0.5.0 // indirect
        github.com/inconshreveable/mousetrap v1.1.0 // indirect
        github.com/k0kubun/pp/v3 v3.2.0 // indirect
        github.com/mattn/go-colorable v0.1.13 // indirect
        github.com/mattn/go-isatty v0.0.16 // indirect
        github.com/spf13/pflag v1.0.5 // indirect
-       golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
+       golang.org/x/sys v0.22.0 // indirect
        golang.org/x/text v0.3.7 // indirect
 )
index 03d714dae3e28c8fc10a47b9ae743b9e98052fda..135f10bc40ddd75b513c64fadfe32fbdfb523e70 100644 (file)
@@ -1,3 +1,5 @@
+github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY=
+github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4=
 github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
 github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
@@ -16,6 +18,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
+golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
diff --git a/documentation/structure-main.d2 b/documentation/structure-main.d2
new file mode 100644 (file)
index 0000000..e77ea19
--- /dev/null
@@ -0,0 +1,26 @@
+sc: scientia
+cfg: config
+cfg_edit: edit
+cfg_init: init
+cfg_read: read
+add: add
+pull: pull
+push: push
+sync: sync
+edit: edit
+edit_id: id
+edit_list: list
+
+sc -> cfg
+cfg -> cfg_init
+cfg -> cfg_edit
+cfg -> cfg_read
+
+sc -> add
+sc -> pull
+sc -> push
+sc -> sync
+
+sc -> edit
+edit -> edit_id
+edit -> edit_list
diff --git a/documentation/structure.d2 b/documentation/structure.d2
deleted file mode 100644 (file)
index 7bd6269..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-sc: scientia
-cfg: config
-cfg_edit: edit
-cfg_init: init
-cfg_read: read
-add: add
-pull: pull
-push: push
-edit: edit
-
-sc -> cfg
-cfg -> cfg_init
-cfg -> cfg_edit
-cfg -> cfg_read
-
-sc -> add
-
-addContainer: add {
-    add_param: file or stdin
-    add_param.shape: oval
-    server: server
-    server.shape: cloud
-    local: local
-    local.shape: page
-
-    add -> add_param
-    add_param -> server
-    server -> local
-    add_param -> local: offline
-}
-
-sc -> pull
-
-pullContainer: pull {
-    server: server
-    server.shape: cloud
-    local: local
-    local.shape: page
-
-    pull -> server
-    server -> local: versions
-}
-
-sc -> push
-
-pushContainer: push {
-    server: server
-    server.shape: cloud
-    local: local
-    local.shape: page
-
-    push -> local
-    local -> server: versions
-}
-
-sc -> edit
-
-editContainer: edit {
-    local: local
-    local.shape: page
-
-    edit_list: list
-    edit_id: id
-
-    edit -> edit_list
-    edit -> edit_id
-
-    edit_id -> local: new version
-}