import (
"errors"
"fmt"
- "github.com/kirsle/configdir"
"github.com/spf13/cobra"
"os"
Helper "scientia/lib"
// 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) {
import (
"errors"
"fmt"
- "github.com/kirsle/configdir"
+ "github.com/adrg/xdg"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"log"
// 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{
)
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
)
+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=
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=
--- /dev/null
+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
+++ /dev/null
-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
-}