From 62228a807d0de19ba490ece287fe0c3cd8648af0 Mon Sep 17 00:00:00 2001 From: Banana Date: Sat, 20 Jul 2024 12:07:48 +0200 Subject: [PATCH] changed to github.com/adrg/xdg Signed-off-by: Banana --- client/go-cli/scientia/cmd/config_init.go | 9 +-- client/go-cli/scientia/cmd/root.go | 6 +- client/go-cli/scientia/go.mod | 3 +- client/go-cli/scientia/go.sum | 4 ++ documentation/structure-main.d2 | 26 +++++++++ documentation/structure.d2 | 69 ----------------------- 6 files changed, 40 insertions(+), 77 deletions(-) create mode 100644 documentation/structure-main.d2 delete mode 100644 documentation/structure.d2 diff --git a/client/go-cli/scientia/cmd/config_init.go b/client/go-cli/scientia/cmd/config_init.go index 43cceb9..f538e4a 100644 --- a/client/go-cli/scientia/cmd/config_init.go +++ b/client/go-cli/scientia/cmd/config_init.go @@ -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) { diff --git a/client/go-cli/scientia/cmd/root.go b/client/go-cli/scientia/cmd/root.go index a1738f8..b2b6260 100644 --- a/client/go-cli/scientia/cmd/root.go +++ b/client/go-cli/scientia/cmd/root.go @@ -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{ diff --git a/client/go-cli/scientia/go.mod b/client/go-cli/scientia/go.mod index 2e863b5..cbecda6 100644 --- a/client/go-cli/scientia/go.mod +++ b/client/go-cli/scientia/go.mod @@ -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 ) diff --git a/client/go-cli/scientia/go.sum b/client/go-cli/scientia/go.sum index 03d714d..135f10b 100644 --- a/client/go-cli/scientia/go.sum +++ b/client/go-cli/scientia/go.sum @@ -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 index 0000000..e77ea19 --- /dev/null +++ b/documentation/structure-main.d2 @@ -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 index 7bd6269..0000000 --- a/documentation/structure.d2 +++ /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 -} -- 2.39.5