diff --git a/.vscode/settings.json b/.vscode/settings.json index 2b37b9d..6a161c7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -29,6 +29,7 @@ "linters", "nakedret", "nolintlint", + "nosec", "pixa", "prealloc", "repotoken", diff --git a/go.mod b/go.mod index b426f06..d5fff88 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/snivilised/arcadia go 1.19 require ( - github.com/onsi/ginkgo/v2 v2.12.1 + github.com/onsi/ginkgo/v2 v2.13.0 github.com/onsi/gomega v1.28.0 github.com/samber/lo v1.38.1 - github.com/snivilised/extendio v0.2.1 + github.com/snivilised/extendio v0.3.0 github.com/spf13/cobra v1.7.0 - github.com/spf13/viper v1.16.0 + github.com/spf13/viper v1.17.0 go.uber.org/zap v1.26.0 ) @@ -20,9 +20,12 @@ require ( github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/sagikazarmark/locafero v0.3.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/tools v0.12.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/tools v0.13.0 // indirect ) require ( @@ -34,14 +37,13 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible github.com/nicksnyder/go-i18n/v2 v2.2.1 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/snivilised/cobrass v0.3.1 - github.com/spf13/afero v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/snivilised/cobrass v0.3.4 + github.com/spf13/afero v1.10.0 // indirect github.com/spf13/cast v1.5.1 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 - github.com/subosito/gotenv v1.4.2 // indirect - golang.org/x/net v0.14.0 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + golang.org/x/net v0.15.0 // indirect golang.org/x/sys v0.12.0 // indirect golang.org/x/text v0.13.0 gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 295b14c..d854a9c 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/cubiest/jibberjabber v1.0.1 h1:JxKC9EZcdw8azEbyWaNj62ppPMkbFJBf2ayPY1vBeDI= github.com/cubiest/jibberjabber v1.0.1/go.mod h1:Ovt9ZAmzAgwQ8cWgvZ1se9oaGYzjHrlAXKM3NOzlQOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -168,56 +168,59 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= -github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.28.0 h1:i2rg/p9n/UqIDAMFUJ6qIUUMcsqOuUHgbpbu235Vr1c= github.com/onsi/gomega v1.28.0/go.mod h1:A1H2JE76sI14WIP57LMKj7FVfCHx3g3BcZVjJG8bjX8= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= +github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= -github.com/snivilised/cobrass v0.3.1 h1:mFakO9fZy2a9BDtO1kpC64Th6atFr98eqOoZJ4WL27s= -github.com/snivilised/cobrass v0.3.1/go.mod h1:2XCuKp20gzk0fQ0Je/hXgwnNbfKFIklDzcSLyQeXs/0= -github.com/snivilised/extendio v0.2.1 h1:nQuzK2V8gWmlGpHSxmFssP72rseFrn87JsbQHmpi7uM= -github.com/snivilised/extendio v0.2.1/go.mod h1:lvlo+FIgk6y2Hk9Nz1uZ0sJ2x4siHyPUpTD0JaVlyvs= -github.com/snivilised/lorax v0.4.0 h1:9Z0be3dW+fjdws7qxfNSse6yjY64WPf44aWz6vVpF9Q= -github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= -github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/snivilised/cobrass v0.3.4 h1:dyIaNHAeX0L57NCirfmrvBAocul0MQiBdW9qZkM1KoQ= +github.com/snivilised/cobrass v0.3.4/go.mod h1:t1xFQENHMDKw4/IDjwb6tL3yOXci6Ps8LjW0BCSluaU= +github.com/snivilised/extendio v0.3.0 h1:lGy33940icaEd20gaDp6nm4ch3FfpMXJUrqpyvWax0E= +github.com/snivilised/extendio v0.3.0/go.mod h1:GZI0mupBlnKu7qXvmvD/slpCa6CxQgQLdD5mvmtsbig= +github.com/snivilised/lorax v0.4.1 h1:4WBPYFeAObXXloBGDnzQPMMS3nb+XuuhdCeaVF2aHLM= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= +github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= -github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= +github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= +github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= -github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -252,8 +255,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -314,8 +317,8 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -446,8 +449,8 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= -golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -540,10 +543,10 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= diff --git a/src/app/command/bootstrap.go b/src/app/command/bootstrap.go index f4dabf2..0686d8d 100644 --- a/src/app/command/bootstrap.go +++ b/src/app/command/bootstrap.go @@ -7,6 +7,7 @@ import ( "github.com/cubiest/jibberjabber" "github.com/samber/lo" "github.com/snivilised/cobrass/src/assistant" + "github.com/snivilised/cobrass/src/assistant/configuration" ci18n "github.com/snivilised/cobrass/src/assistant/i18n" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -31,17 +32,52 @@ func (j *Jabber) Scan() language.Tag { return language.MustParse(lang) } +type ConfigInfo struct { + Name string + ConfigType string + ConfigPath string + Viper configuration.ViperConfig +} + +type ConfigureOptions struct { + Detector LocaleDetector + Config ConfigInfo +} + +type ConfigureOptionFn func(*ConfigureOptions) + // Bootstrap represents construct that performs start up of the cli // without resorting to the use of Go's init() mechanism and minimal // use of package global variables. type Bootstrap struct { - Detector LocaleDetector container *assistant.CobraContainer + options ConfigureOptions +} + +func (b *Bootstrap) prepare() { + home, err := os.UserHomeDir() + cobra.CheckErr(err) + + b.options = ConfigureOptions{ + Detector: &Jabber{}, + Config: ConfigInfo{ + Name: ApplicationName, + ConfigType: "yaml", + ConfigPath: home, + Viper: &configuration.GlobalViperConfig{}, + }, + } } // Root builds the command tree and returns the root command, ready // to be executed. -func (b *Bootstrap) Root() *cobra.Command { +func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command { + b.prepare() + + for _, fo := range options { + fo(&b.options) + } + b.configure() // all these string literals here should be made translate-able @@ -60,48 +96,21 @@ func (b *Bootstrap) Root() *cobra.Command { ) b.buildRootCommand(b.container) - buildWidgetCommand(b.container) + b.buildWidgetCommand(b.container) return b.container.Root() } -type configureOptions struct { - configFile *string -} - -type ConfigureOptionFn func(*configureOptions) - -func (b *Bootstrap) configure(options ...ConfigureOptionFn) { - var configFile string - - o := configureOptions{ - configFile: &configFile, - } - for _, fo := range options { - fo(&o) - } - - if configFile != "" { - // Use config file from the flag. - viper.SetConfigFile(configFile) - } else { - // Find home directory. - home, err := os.UserHomeDir() - cobra.CheckErr(err) - - // Search config in home directory with name ".arcadia" (without extension). - // NB: 'arcadia' should be renamed as appropriate - // - viper.AddConfigPath(home) - viper.SetConfigType("yaml") - configName := fmt.Sprintf("%v.yml", ApplicationName) - viper.SetConfigName(configName) - } +func (b *Bootstrap) configure() { + vc := b.options.Config.Viper + ci := b.options.Config - viper.AutomaticEnv() // read in environment variables that match + vc.SetConfigName(ci.Name) + vc.SetConfigType(ci.ConfigType) + vc.AddConfigPath(ci.ConfigPath) + vc.AutomaticEnv() - // If a config file is found, read it in. - err := viper.ReadInConfig() + err := vc.ReadInConfig() handleLangSetting() @@ -167,15 +176,6 @@ func (b *Bootstrap) buildRootCommand(container *assistant.CobraContainer) { root := container.Root() paramSet := assistant.NewParamSet[RootParameterSet](root) - paramSet.BindString(&assistant.FlagInfo{ - Name: "config", - Usage: xi18n.Text(i18n.RootCmdConfigFileUsageTemplData{ - ConfigFileName: ApplicationName, - }), - Default: "", - AlternativeFlagSet: root.PersistentFlags(), - }, ¶mSet.Native.ConfigFile) - paramSet.BindValidatedString(&assistant.FlagInfo{ Name: "lang", Usage: xi18n.Text(i18n.RootCmdLangUsageTemplData{}), diff --git a/src/app/command/bootstrap_test.go b/src/app/command/bootstrap_test.go index 5ce401e..2893f34 100644 --- a/src/app/command/bootstrap_test.go +++ b/src/app/command/bootstrap_test.go @@ -10,6 +10,11 @@ import ( "golang.org/x/text/language" ) +const ( + configName = "arcadia-test" + configPath = "../../test/data/configuration" +) + type DetectorStub struct { } @@ -32,10 +37,12 @@ var _ = Describe("Bootstrap", Ordered, func() { Context("given: root defined with widget sub-command", func() { It("🧪 should: setup command without error", func() { - bootstrap := command.Bootstrap{ - Detector: &DetectorStub{}, - } - rootCmd := bootstrap.Root() + bootstrap := command.Bootstrap{} + rootCmd := bootstrap.Root(func(co *command.ConfigureOptions) { + co.Detector = &DetectorStub{} + co.Config.Name = configName + co.Config.ConfigPath = configPath + }) Expect(rootCmd).NotTo(BeNil()) }) }) diff --git a/src/app/command/root-cmd.go b/src/app/command/root-cmd.go index 446fe0d..0bb44d6 100644 --- a/src/app/command/root-cmd.go +++ b/src/app/command/root-cmd.go @@ -3,10 +3,6 @@ Copyright © 2022 NAME HERE */ package command -import ( - xi18n "github.com/snivilised/extendio/i18n" -) - const ( AppEmoji = "🦄" ApplicationName = "arcadia" @@ -14,30 +10,11 @@ const ( SourceID = "github.com/snivilised/arcadia" ) -type ExecutionOptions struct { - Detector LocaleDetector - From *xi18n.LoadFrom -} - -type ExecutionOptionsFn func(o *ExecutionOptions) - -func Execute(setter ...ExecutionOptionsFn) error { - o := &ExecutionOptions{ - Detector: &Jabber{}, - } - if len(setter) > 0 { - setter[0](o) - } - - bootstrap := Bootstrap{ - Detector: o.Detector, - } - - return bootstrap.Root().Execute() +func Execute() error { + return (&Bootstrap{}).Root().Execute() } // CLIENT-TODO: define valid properties on the root parameter set type RootParameterSet struct { - ConfigFile string - Language string + Language string } diff --git a/src/app/command/root-cmd_test.go b/src/app/command/root-cmd_test.go index 57690ee..bf7f2e1 100644 --- a/src/app/command/root-cmd_test.go +++ b/src/app/command/root-cmd_test.go @@ -22,12 +22,14 @@ var _ = Describe("RootCmd", Ordered, func() { }) It("🧪 should: execute", func() { - bootstrap := command.Bootstrap{ - Detector: &DetectorStub{}, - } + bootstrap := command.Bootstrap{} tester := helpers.CommandTester{ Args: []string{}, - Root: bootstrap.Root(), + Root: bootstrap.Root(func(co *command.ConfigureOptions) { + co.Detector = &DetectorStub{} + co.Config.Name = configName + co.Config.ConfigPath = configPath + }), } _, err := tester.Execute() Expect(err).Error().To(BeNil()) diff --git a/src/app/command/widget-cmd.go b/src/app/command/widget-cmd.go index fd0e53d..9e82fdc 100644 --- a/src/app/command/widget-cmd.go +++ b/src/app/command/widget-cmd.go @@ -22,7 +22,7 @@ import ( const widgetPsName = "widget-ps" -func buildWidgetCommand(container *assistant.CobraContainer) *cobra.Command { +func (b *Bootstrap) buildWidgetCommand(container *assistant.CobraContainer) *cobra.Command { // to test: arcadia widget -d ./some-existing-file -p "P?" -t 30 // widgetCommand := &cobra.Command{ diff --git a/src/app/command/widget_cmd_test.go b/src/app/command/widget_cmd_test.go index 85d9ad9..0acc431 100644 --- a/src/app/command/widget_cmd_test.go +++ b/src/app/command/widget_cmd_test.go @@ -5,6 +5,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/spf13/cobra" "github.com/snivilised/arcadia/src/app/command" "github.com/snivilised/arcadia/src/i18n" @@ -17,8 +18,10 @@ import ( var _ = Describe("WidgetCmd", Ordered, func() { var ( - repo string - l10nPath string + repo string + l10nPath string + bootstrap command.Bootstrap + rootCommand *cobra.Command ) BeforeAll(func() { @@ -49,16 +52,19 @@ var _ = Describe("WidgetCmd", Ordered, func() { if err != nil { Fail(err.Error()) } + bootstrap = command.Bootstrap{} + rootCommand = bootstrap.Root(func(co *command.ConfigureOptions) { + co.Detector = &DetectorStub{} + co.Config.Name = configName + co.Config.ConfigPath = configPath + }) }) When("specified flags are valid", func() { It("🧪 should: execute without error", func() { - bootstrap := command.Bootstrap{ - Detector: &DetectorStub{}, - } tester := helpers.CommandTester{ Args: []string{"widget", "-p", "P?", "-t", "42"}, - Root: bootstrap.Root(), + Root: rootCommand, } _, err := tester.Execute() Expect(err).Error().To(BeNil(), @@ -69,12 +75,9 @@ var _ = Describe("WidgetCmd", Ordered, func() { When("specified flags are valid", func() { It("🧪 should: return error due to option validation failure", func() { - bootstrap := command.Bootstrap{ - Detector: &DetectorStub{}, - } tester := helpers.CommandTester{ Args: []string{"widget", "-p", "P?", "-t", "99"}, - Root: bootstrap.Root(), + Root: rootCommand, } _, err := tester.Execute() Expect(err).Error().NotTo(BeNil(), diff --git a/src/app/domain/domain-defs.go b/src/app/domain/domain-defs.go new file mode 100644 index 0000000..156a6ae --- /dev/null +++ b/src/app/domain/domain-defs.go @@ -0,0 +1,7 @@ +package domain + +type Executor interface { + ProgName() string + Look() (string, error) + Execute(args ...string) error +}