Skip to content

Commit

Permalink
Add custom app name color
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Jan 7, 2022
1 parent 2889d05 commit eabde4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ jobs:

- name: Login to DockerHub
uses: docker/login-action@v1
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
if: ${{ env.DOCKERHUB_USERNAME != '' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
26 changes: 20 additions & 6 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
// Application info
const (
APP = "bibop"
VER = "5.1.0"
VER = "5.1.1"
DESC = "Utility for testing command-line tools"
)

Expand Down Expand Up @@ -84,6 +84,9 @@ var optMap = options.Map{
OPT_GENERATE_MAN: {Type: options.BOOL},
}

var colorTagApp string
var colorTagVer string

// ////////////////////////////////////////////////////////////////////////////////// //

func Init() {
Expand All @@ -106,7 +109,6 @@ func Init() {
}

configureUI()
configureSubsystems()

if options.GetB(OPT_VER) {
showAbout()
Expand All @@ -118,6 +120,8 @@ func Init() {
os.Exit(0)
}

configureSubsystems()

validateOptions()
process(args[0])
}
Expand All @@ -134,11 +138,16 @@ func configureUI() {

fmtutil.SeparatorSymbol = "–"

if fmtc.Is256ColorsSupported() {
fmtutil.SeparatorTitleColorTag = "{#85}"
} else {
fmtutil.SeparatorTitleColorTag = "{c*}"
switch {
case fmtc.IsTrueColorSupported():
colorTagApp, colorTagVer = "{#66CC99}", "{#66CC99}"
case fmtc.Is256ColorsSupported():
colorTagApp, colorTagVer = "{#85}", "{#85}"
default:
colorTagApp, colorTagVer = "{c}", "{c}"
}

fmtutil.SeparatorTitleColorTag = colorTagApp
}

// configureSubsystems configures bibop subsystems
Expand Down Expand Up @@ -380,6 +389,8 @@ func genMan() int {
func genUsage() *usage.Info {
info := usage.NewInfo("", "recipe")

info.AppNameColorTag = "{*}" + colorTagApp

info.AddOption(OPT_DRY_RUN, "Parse and validate recipe")
info.AddOption(OPT_LIST_PACKAGES, "List required packages")
info.AddOption(OPT_FORMAT, "Output format {s-}(tap|json|xml){!}", "format")
Expand Down Expand Up @@ -428,6 +439,9 @@ func genAbout() *usage.About {
License: "Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>",
BugTracker: "https://github.com/essentialkaos/bibop/issues",
UpdateChecker: usage.UpdateChecker{"essentialkaos/bibop", update.GitHubChecker},

AppNameColorTag: "{*}" + colorTagApp,
VersionColorTag: colorTagVer,
}

return about
Expand Down

0 comments on commit eabde4e

Please sign in to comment.