Skip to content

Commit

Permalink
Merge pull request #2 from lukasz-lobocki/clickable-links
Browse files Browse the repository at this point in the history
feat(columns): Clickable dir and url
  • Loading branch information
lukasz-lobocki authored Oct 7, 2023
2 parents 89e2e85 + d0ae56b commit 27e7146
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
8 changes: 3 additions & 5 deletions cmd/root__command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down
18 changes: 13 additions & 5 deletions cmd/status_colums.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 ""
},
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=

0 comments on commit 27e7146

Please sign in to comment.