Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
035b70af70 | ||
![]() |
ed71652c98 | ||
![]() |
e1fb0ef7f1 | ||
![]() |
614119b22d |
@ -1,6 +1,6 @@
|
||||
linters-settings:
|
||||
gocyclo:
|
||||
min-complexity: 21
|
||||
min-complexity: 30
|
||||
tagliatelle:
|
||||
case:
|
||||
rules:
|
||||
@ -9,7 +9,6 @@ linters-settings:
|
||||
linters:
|
||||
fast: false
|
||||
enable:
|
||||
- deadcode
|
||||
- errcheck
|
||||
- exportloopref
|
||||
- goconst
|
||||
@ -21,7 +20,6 @@ linters:
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ifshort
|
||||
- ineffassign
|
||||
- misspell
|
||||
- nakedret
|
||||
@ -29,12 +27,10 @@ linters:
|
||||
- prealloc
|
||||
- revive
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- tagliatelle
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
||||
- whitespace
|
||||
|
@ -1 +1 @@
|
||||
golang 1.20.2
|
||||
golang 1.22.3
|
||||
|
38
go.mod
38
go.mod
@ -1,42 +1,42 @@
|
||||
module git.rob.mx/nidito/chinampa
|
||||
|
||||
go 1.20
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/charmbracelet/glamour v0.6.0
|
||||
github.com/fatih/color v1.15.0
|
||||
github.com/go-playground/validator/v10 v10.15.3
|
||||
github.com/charmbracelet/glamour v0.7.0
|
||||
github.com/fatih/color v1.17.0
|
||||
github.com/go-playground/validator/v10 v10.20.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/spf13/cobra v1.7.0
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
golang.org/x/term v0.12.0
|
||||
golang.org/x/term v0.20.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/alecthomas/chroma v0.10.0 // indirect
|
||||
github.com/alecthomas/chroma/v2 v2.13.0 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.10.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/gorilla/css v1.0.0 // indirect
|
||||
github.com/gorilla/css v1.0.1 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
|
||||
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
|
||||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/termenv v0.15.2 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/yuin/goldmark v1.5.6 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/yuin/goldmark v1.7.1 // indirect
|
||||
github.com/yuin/goldmark-emoji v1.0.2 // indirect
|
||||
golang.org/x/crypto v0.12.0 // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
)
|
||||
|
103
go.sum
103
go.sum
@ -1,54 +1,56 @@
|
||||
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
|
||||
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
|
||||
github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4=
|
||||
github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
|
||||
github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||
github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
|
||||
github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
|
||||
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
|
||||
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||
github.com/charmbracelet/glamour v0.6.0 h1:wi8fse3Y7nfcabbbDuwolqTqMQPMnVPeZhDM273bISc=
|
||||
github.com/charmbracelet/glamour v0.6.0/go.mod h1:taqWV4swIMMbWALc0m7AfE9JkPSU8om2538k9ITBxOc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng=
|
||||
github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
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/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
|
||||
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
||||
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
||||
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
|
||||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.15.3 h1:S+sSpunYjNPDuXkWbK+x+bA7iXiW296KG4dL3X7xUZo=
|
||||
github.com/go-playground/validator/v10 v10.15.3/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
|
||||
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
||||
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM=
|
||||
github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg=
|
||||
github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE=
|
||||
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
|
||||
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
|
||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
||||
github.com/muesli/termenv v0.13.0/go.mod h1:sP1+uffeLaEYpyOTb8pLCUctGcGLnoFjSn4YJK5e2bc=
|
||||
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
|
||||
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
@ -57,50 +59,37 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
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/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||
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/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.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.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
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/yuin/goldmark v1.3.7/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.5.2/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yuin/goldmark v1.5.6 h1:COmQAWTCcGetChm3Ig7G/t8AFAN00t+o8Mt4cf7JpwA=
|
||||
github.com/yuin/goldmark v1.5.6/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ=
|
||||
github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U=
|
||||
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s=
|
||||
github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY=
|
||||
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@ -72,10 +72,10 @@ By default, and unless ﹅` + env.NoColor + `﹅ is set, ﹅@chinampa@ help﹅ w
|
||||
logrus.Errorf("Unknown help topic \"%s\"", args[0])
|
||||
}
|
||||
os.Exit(statuscode.NotFound)
|
||||
} else {
|
||||
}
|
||||
|
||||
c.InitDefaultHelpFlag() // make possible 'help' flag to be shown
|
||||
cobra.CheckErr(c.Help())
|
||||
}
|
||||
|
||||
os.Exit(statuscode.RenderHelp)
|
||||
},
|
||||
|
@ -64,7 +64,7 @@ description: {{ .Command.Short }}
|
||||
## Options
|
||||
|
||||
{{ range $name, $opt := .Spec.Options -}}
|
||||
- `--{{ $name }}` (_{{$opt.Type}}_): {{ trimSuffix $opt.Description "."}}.{{ if $opt.Default }} Default: _{{ $opt.Default }}_.{{ end }}
|
||||
- `--{{ $name }}` (_{{if $opt.Repeated}}[]{{end}}{{$opt.Type}}_): {{ trimSuffix $opt.Description "."}}.{{if $opt.Repeated}} May be specified more than once. {{end}}{{ if $opt.Default }} Default: _{{ $opt.Default }}_.{{ end }}
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
// ContextKeyRuntimeIndex is the string key used to store context in a cobra Command.
|
||||
const ContextKeyRuntimeIndex = "x-chinampa-runtime-index"
|
||||
const ContextKeyRuntimeIndex = "x-chinampa-runtime-index" // nolint:gosec
|
||||
|
||||
var ErrorHandler = errors.HandleCobraExit
|
||||
|
||||
@ -137,7 +137,7 @@ func Execute(version string) error {
|
||||
|
||||
if !found {
|
||||
groupName := strings.Join(query, " ")
|
||||
cleanPath := append(cmd.Path[0:idx], query...)
|
||||
cleanPath := append(cmd.Path[0:idx], query...) // nolint:gocritic
|
||||
groupPath := append(cmdRoot.Path, cleanPath...) // nolint:gocritic
|
||||
|
||||
cmdGlobalOptions := globalOptions
|
||||
|
@ -98,11 +98,31 @@ func (cmd *Command) FlagSet() *pflag.FlagSet {
|
||||
fs.IntP(name, opt.ShortName, def, opt.Description)
|
||||
case ValueTypeDefault, ValueTypeString:
|
||||
opt.Type = ValueTypeString
|
||||
if opt.Repeated {
|
||||
def := []string{}
|
||||
if opt.Default != nil {
|
||||
switch defV := opt.Default.(type) {
|
||||
case []any:
|
||||
for _, v := range defV {
|
||||
def = append(def, fmt.Sprintf("%s", v))
|
||||
}
|
||||
case []string:
|
||||
def = defV
|
||||
case string:
|
||||
def = []string{defV}
|
||||
default:
|
||||
logger.Errorf("Invalid default for repeated option %s configuration: %+v", name, defV)
|
||||
}
|
||||
}
|
||||
|
||||
fs.StringArrayP(name, opt.ShortName, def, opt.Description)
|
||||
} else {
|
||||
def := ""
|
||||
if opt.Default != nil {
|
||||
def = fmt.Sprintf("%s", opt.Default)
|
||||
}
|
||||
fs.StringP(name, opt.ShortName, def, opt.Description)
|
||||
}
|
||||
default:
|
||||
// ignore flag
|
||||
log.Warnf("Ignoring unknown option type <%s> for option <%s>", opt.Type, name)
|
||||
|
@ -45,7 +45,7 @@ func (cmd *Command) HelpRenderer(globalOptions Options) func(cc *cobra.Command,
|
||||
}
|
||||
}
|
||||
|
||||
func (cmd *Command) ShowHelp(globalOptions Options, args []string) ([]byte, error) {
|
||||
func (cmd *Command) ShowHelp(globalOptions Options, _ []string) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
colorEnabled := runtime.ColorEnabled()
|
||||
c := &combinedCommand{
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.rob.mx/nidito/chinampa/pkg/errors"
|
||||
"git.rob.mx/nidito/chinampa/pkg/logger"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
@ -15,6 +16,7 @@ import (
|
||||
// Options is a map of name to Option.
|
||||
type Options map[string]*Option
|
||||
|
||||
// AllKnown returns a map of option names to their resolved values.
|
||||
func (opts *Options) AllKnown() map[string]any {
|
||||
col := map[string]any{}
|
||||
for name, opt := range *opts {
|
||||
@ -23,6 +25,7 @@ func (opts *Options) AllKnown() map[string]any {
|
||||
return col
|
||||
}
|
||||
|
||||
// AllKnownStr returns a map of option names to their stringified values.
|
||||
func (opts *Options) AllKnownStr() map[string]string {
|
||||
col := map[string]string{}
|
||||
for name, opt := range *opts {
|
||||
@ -31,6 +34,7 @@ func (opts *Options) AllKnownStr() map[string]string {
|
||||
return col
|
||||
}
|
||||
|
||||
// Parse populates values with those supplied in the provided pflag.Flagset.
|
||||
func (opts *Options) Parse(supplied *pflag.FlagSet) {
|
||||
// log.Debugf("Parsing supplied flags, %v", supplied)
|
||||
for name, opt := range *opts {
|
||||
@ -47,14 +51,24 @@ func (opts *Options) Parse(supplied *pflag.FlagSet) {
|
||||
}
|
||||
default:
|
||||
opt.Type = ValueTypeString
|
||||
if opt.Repeated {
|
||||
val, err := supplied.GetStringArray(name)
|
||||
if err == nil {
|
||||
opt.provided = val
|
||||
continue
|
||||
}
|
||||
logger.Errorf("Invalid option configuration: %s", err)
|
||||
} else {
|
||||
if val, err := supplied.GetString(name); err == nil {
|
||||
opt.provided = val
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AreValid tells if these options are all valid.
|
||||
func (opts *Options) AreValid() error {
|
||||
for name, opt := range *opts {
|
||||
if err := opt.Validate(name); err != nil {
|
||||
@ -67,20 +81,29 @@ func (opts *Options) AreValid() error {
|
||||
|
||||
// Option represents a command line flag.
|
||||
type Option struct {
|
||||
ShortName string `json:"short-name,omitempty" yaml:"short-name,omitempty"` // nolint:tagliatelle
|
||||
// Type represents the type of value expected to be provided for this option.
|
||||
Type ValueType `json:"type" yaml:"type" validate:"omitempty,oneof=string bool int"`
|
||||
// Description is a required field that show up during completions and help.
|
||||
Description string `json:"description" yaml:"description" validate:"required"`
|
||||
// Default value for this option, if none provided.
|
||||
Default any `json:"default,omitempty" yaml:"default,omitempty"`
|
||||
// ShortName When set, enables representing this Option as a short flag (-x).
|
||||
ShortName string `json:"short-name,omitempty" yaml:"short-name,omitempty"` // nolint:tagliatelle
|
||||
// Values denote the source for completion/validation values of this option.
|
||||
Values *ValueSource `json:"values,omitempty" yaml:"values,omitempty" validate:"omitempty"`
|
||||
// Repeated options may be specified more than once.
|
||||
Repeated bool `json:"repeated" yaml:"repeated" validate:"omitempty"`
|
||||
// Command references the Command this Option is defined for.
|
||||
Command *Command `json:"-" yaml:"-" validate:"-"`
|
||||
provided any
|
||||
}
|
||||
|
||||
// IsKnown tells if the option was provided by the user.
|
||||
func (opt *Option) IsKnown() bool {
|
||||
return opt.provided != nil
|
||||
}
|
||||
|
||||
// Returns the resolved value for an option.
|
||||
func (opt *Option) ToValue() any {
|
||||
if opt.IsKnown() {
|
||||
return opt.provided
|
||||
@ -88,6 +111,7 @@ func (opt *Option) ToValue() any {
|
||||
return opt.Default
|
||||
}
|
||||
|
||||
// Returns a string representation of this Option's resolved value.
|
||||
func (opt *Option) ToString() string {
|
||||
value := opt.ToValue()
|
||||
stringValue := ""
|
||||
@ -102,7 +126,7 @@ func (opt *Option) ToString() string {
|
||||
if value == nil {
|
||||
stringValue = ""
|
||||
} else {
|
||||
stringValue = fmt.Sprintf("%i", value)
|
||||
stringValue = fmt.Sprintf("%d", value)
|
||||
}
|
||||
default:
|
||||
if value != nil {
|
||||
@ -113,13 +137,7 @@ func (opt *Option) ToString() string {
|
||||
return stringValue
|
||||
}
|
||||
|
||||
func (opt *Option) Validate(name string) error {
|
||||
if !opt.Validates() {
|
||||
return nil
|
||||
}
|
||||
|
||||
current := opt.ToString() // nolint:ifshort
|
||||
|
||||
func (opt *Option) internalValidate(name, current string) error {
|
||||
if current == "" {
|
||||
return nil
|
||||
}
|
||||
@ -136,6 +154,28 @@ func (opt *Option) Validate(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate validates the provided value if a value source.
|
||||
func (opt *Option) Validate(name string) error {
|
||||
if !opt.Validates() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if opt.Repeated {
|
||||
values := opt.ToValue().([]string)
|
||||
for _, current := range values {
|
||||
if err := opt.internalValidate(name, current); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := opt.internalValidate(name, opt.ToString()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validates tells if the user-supplied value needs validation.
|
||||
func (opt *Option) Validates() bool {
|
||||
return opt.Values != nil && opt.Values.Validates()
|
||||
@ -161,12 +201,14 @@ func (opt *Option) Resolve(currentValue string) (values []string, flag cobra.She
|
||||
// CompletionFunction is called by cobra when asked to complete an option.
|
||||
func (opt *Option) CompletionFunction(cmd *cobra.Command, args []string, toComplete string) (values []string, flag cobra.ShellCompDirective) {
|
||||
if !opt.providesAutocomplete() {
|
||||
logger.Tracef("Option does not provide autocomplete %+v", opt)
|
||||
flag = cobra.ShellCompDirectiveNoFileComp
|
||||
return
|
||||
}
|
||||
|
||||
if err := opt.Command.Arguments.Parse(args); err != nil {
|
||||
return []string{err.Error()}, cobra.ShellCompDirectiveDefault
|
||||
logger.Errorf("Could not parse command arguments %s", err)
|
||||
return []string{}, cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
opt.Command.Options.Parse(cmd.Flags())
|
||||
|
||||
|
@ -41,6 +41,10 @@ func withEnv(t *testing.T, env map[string]string) {
|
||||
})
|
||||
}
|
||||
|
||||
func escaped(a string) string {
|
||||
return strings.ReplaceAll(a, "\033", "\\033")
|
||||
}
|
||||
|
||||
func TestFormatter(t *testing.T) {
|
||||
now := strings.Replace(time.Now().Local().Format(time.DateTime), " ", "T", 1)
|
||||
cases := []struct {
|
||||
@ -60,7 +64,7 @@ func TestFormatter(t *testing.T) {
|
||||
Color: true,
|
||||
Verbose: true,
|
||||
Call: Info,
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[0m \033[2minfo\033[0m\033[2m\033[0m message", now),
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[22m \033[2minfo\033[22m\033[2m\033[22m message", now),
|
||||
Level: logrus.InfoLevel,
|
||||
},
|
||||
{
|
||||
@ -77,14 +81,14 @@ func TestFormatter(t *testing.T) {
|
||||
{
|
||||
Color: true,
|
||||
Call: Debug,
|
||||
Expects: "\033[2mDEBUG: \033[0m\033[2mmessage\033[0m",
|
||||
Expects: "\033[2mDEBUG: \033[22m\033[2mmessage\033[22m",
|
||||
Level: logrus.DebugLevel,
|
||||
},
|
||||
{
|
||||
Color: true,
|
||||
Verbose: true,
|
||||
Call: Debug,
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[0m \033[2mdebug\033[0m\033[2m\033[0m\t\033[2mmessage\033[0m",
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[22m \033[2mdebug\033[22m\033[2m\033[22m\t\033[2mmessage\033[22m",
|
||||
now),
|
||||
Level: logrus.DebugLevel,
|
||||
},
|
||||
@ -113,13 +117,13 @@ func TestFormatter(t *testing.T) {
|
||||
Level: logrus.InfoLevel,
|
||||
Color: true,
|
||||
Verbose: true,
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[0m \033[1;93mwarning\033[0m\033[2m\033[0m\tmessage", now),
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[22m \033[1;93mwarning\033[22;0m\033[2m\033[22m\tmessage", now),
|
||||
},
|
||||
{
|
||||
Call: Warn,
|
||||
Level: logrus.InfoLevel,
|
||||
Color: true,
|
||||
Expects: "\033[1;43;30m WARNING \033[0m message",
|
||||
Expects: "\033[1;43;30m WARNING \033[22;0;0m message",
|
||||
},
|
||||
{
|
||||
Call: Error,
|
||||
@ -136,13 +140,13 @@ func TestFormatter(t *testing.T) {
|
||||
Level: logrus.InfoLevel,
|
||||
Color: true,
|
||||
Verbose: true,
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[0m \033[1;91merror\033[0m\033[2m\033[0m\tmessage", now),
|
||||
Expects: fmt.Sprintf("\033[2m%s\033[22m \033[1;91merror\033[22;0m\033[2m\033[22m\tmessage", now),
|
||||
},
|
||||
{
|
||||
Call: Error,
|
||||
Level: logrus.InfoLevel,
|
||||
Color: true,
|
||||
Expects: "\033[1;41;225m ERROR \033[0m message",
|
||||
Expects: "\033[1;41;225m ERROR \033[22;0;0m message",
|
||||
},
|
||||
}
|
||||
|
||||
@ -180,7 +184,7 @@ func TestFormatter(t *testing.T) {
|
||||
}
|
||||
|
||||
if res := data.String(); res != expected {
|
||||
t.Fatalf("%s:\ngot : %s\nwanted: %v", name, res, expected)
|
||||
t.Fatalf("%s:\ngot : %s\nwanted: %v", name, escaped(res), escaped(expected))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
package tree
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sort"
|
||||
|
||||
"git.rob.mx/nidito/chinampa/internal/registry"
|
||||
@ -31,8 +32,12 @@ func (t *CommandTree) Traverse(fn func(cmd *command.Command) error) error {
|
||||
var tree *CommandTree
|
||||
|
||||
func Build(cc *cobra.Command, depth int) {
|
||||
root := registry.FromCobra(cc)
|
||||
if root == nil && cc.Root() == cc {
|
||||
root = command.Root
|
||||
}
|
||||
tree = &CommandTree{
|
||||
Command: registry.FromCobra(cc),
|
||||
Command: root,
|
||||
Children: []*CommandTree{},
|
||||
}
|
||||
|
||||
@ -59,11 +64,11 @@ func Build(cc *cobra.Command, depth int) {
|
||||
}
|
||||
|
||||
func Serialize(serializationFn func(any) ([]byte, error)) (string, error) {
|
||||
bytes, err := serializationFn(tree)
|
||||
content, err := serializationFn(tree)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(bytes), nil
|
||||
return string(bytes.ReplaceAll(content, []byte("﹅"), []byte("`"))), nil
|
||||
}
|
||||
|
||||
func ChildrenNames() []string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user