From d0ae56b4bd70c9905d6855d1e1f757b22bb81e24 Mon Sep 17 00:00:00 2001 From: lukasz-lobocki Date: Sat, 7 Oct 2023 11:09:22 +0200 Subject: [PATCH] feat(columns): Clickable dir and url --- cmd/root__command.go | 8 +++----- cmd/status_colums.go | 18 +++++++++++++----- go.mod | 10 ++++++---- go.sum | 8 ++++++-- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/cmd/root__command.go b/cmd/root__command.go index 3e7aeb6..7673fca 100644 --- a/cmd/root__command.go +++ b/cmd/root__command.go @@ -15,11 +15,9 @@ Version numer shown in help message. `version` is updated with `-ldflags` during sem_release_ver+architecture.short_git_hash[.dirty.build_date] */ var ( - semVer, commitHash string - isGitDirty, isSnapshot string - goOs, goArch string - gitUrl, builtBranch string - builtDate, builtBy string + semVer string + commitHash string + goArch string ) var semReleaseVersion string = semVer + diff --git a/cmd/status_colums.go b/cmd/status_colums.go index 4a6cced..43f2f5f 100644 --- a/cmd/status_colums.go +++ b/cmd/status_colums.go @@ -16,6 +16,13 @@ type tColumn struct { contentEscapeMD bool } +/* +getClickable returns linkText string that is clickable in GNOME and spawns url +*/ +func getClickable(linkText string, url string) string { + return "\033]8;;" + url + "\a" + linkText + "\033]8;;\a" +} + /* getColumns defines look and content of table's emitted columns */ @@ -43,11 +50,11 @@ func getColumns() []tColumn { contentSource: func(tc tConfig, tr tRepo) string { switch tc.nameShown.Value { // Content differs by config case "p": - return tr.TopLevelPath + return getClickable(tr.TopLevelPath, "file:///"+tr.TopLevelPath) case "s": - return tr.ShortName + return getClickable(tr.ShortName, "file:///"+tr.TopLevelPath) case "u": - return tr.UniqueName + return getClickable(tr.UniqueName, "file:///"+tr.TopLevelPath) } return "" }, @@ -104,9 +111,10 @@ func getColumns() []tColumn { titleColor: color.Bold, contentSource: func(_ tConfig, tr tRepo) string { - return strings.ReplaceAll( + return getClickable(tr.OriginUrl, strings.ReplaceAll(tr.OriginUrl, "ssh://git@", "https://")) + /* return strings.ReplaceAll( tr.OriginUrl, "git@github.com:", "ssh@https://github.com/", // To provide clickable text in the output - ) + ) */ }, contentColor: func(_ tRepo) color.Attribute { return color.FgWhite }, // Static color contentAlignMD: ALIGN_LEFT, diff --git a/go.mod b/go.mod index 2a8b2fe..af082d4 100644 --- a/go.mod +++ b/go.mod @@ -2,18 +2,20 @@ module github.com/lukasz-lobocki/gitas go 1.21.1 +replace github.com/lukasz-lobocki/tabby => /home/lukasz-lobocki/Code/golang/tabby/ + require ( github.com/briandowns/spinner v1.23.0 github.com/fatih/color v1.15.0 - github.com/lukasz-lobocki/tabby v1.0.5 + github.com/lukasz-lobocki/tabby v1.0.6 github.com/spf13/cobra v1.7.0 ) require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/term v0.1.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect ) diff --git a/go.sum b/go.sum index fbb633d..78f7b77 100644 --- a/go.sum +++ b/go.sum @@ -5,13 +5,13 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/lukasz-lobocki/tabby v1.0.5 h1:xiLh9DXAof8dUcfE0SflQ91532ovtjF4wlL53mHdQE0= -github.com/lukasz-lobocki/tabby v1.0.5/go.mod h1:npL3zCVTzd1S4x0eSp1FD+SaxBTN6pQZSLWck04Wxyo= 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.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/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/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= @@ -20,7 +20,11 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=