Skip to content

Commit

Permalink
Merge pull request #155 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 2.2.0
  • Loading branch information
andyone authored May 21, 2024
2 parents bd8f261 + 98318ba commit f190298
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
aligo
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

# This Makefile generated by GoMakeGen 3.0.0 using next command:
# This Makefile generated by GoMakeGen 3.0.1 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
Expand All @@ -25,15 +25,15 @@ GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)
all: aligo ## Build all binaries

aligo:
@echo "[37m[1/1][0m [36;1mBuilding aligo…[0m"
@echo "[36;1mBuilding aligo…[0m"
@go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" aligo.go

install: ## Install all binaries
@echo "[37m[1/1][0m [36;1mInstalling binaries…[0m"
@echo "[36;1mInstalling binaries…[0m"
@cp aligo /usr/bin/aligo

uninstall: ## Uninstall all binaries
@echo "[37m[1/1][0m [36;1mRemoving installed binaries…[0m"
@echo "[36;1mRemoving installed binaries…[0m"
@rm -f /usr/bin/aligo

init: mod-init ## Initialize new module
Expand Down Expand Up @@ -81,23 +81,23 @@ endif
@test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

mod-download:
@echo "[37m[1/1][0m [36;1mDownloading dependencies…[0m"
@echo "[36;1mDownloading dependencies…[0m"
@go mod download

mod-vendor:
@echo "[37m[1/1][0m [36;1mVendoring dependencies…[0m"
@echo "[36;1mVendoring dependencies…[0m"
@rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

fmt: ## Format source code with gofmt
@echo "[37m[1/1][0m [36;1mFormatting sources…[0m"
@echo "[36;1mFormatting sources…[0m"
@find . -name "*.go" -exec gofmt -s -w {} \;

vet: ## Runs 'go vet' over sources
@echo "[37m[1/1][0m [36;1mRunning 'go vet' over sources…[0m"
@echo "[36;1mRunning 'go vet' over sources…[0m"
@go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...

clean: ## Remove generated files
@echo "[37m[1/1][0m [36;1mRemoving built binaries…[0m"
@echo "[36;1mRemoving built binaries…[0m"
@rm -f aligo

help: ## Show this info
Expand All @@ -109,6 +109,6 @@ help: ## Show this info
| sed 's/ifdef //' \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 3.0.0\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 3.0.1\033[0m\n'

################################################################################
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
</p>

<p align="center"><a href="#screenshots">Screenshots</a> • <a href="#installation">Installation</a> • <a href="#command-line-completion">Command-line completion</a> • <a href="#man-documentation">Man documentation</a> • <a href="#faq">FAQ</a> • <a href="#usage">Usage</a> • <a href="#build-status">Build Status</a> • <a href="#contributing">Contributing</a> • <a href="#thanks">Thanks</a> • <a href="#license">License</a></p>
<p align="center"><a href="#screenshots">Screenshots</a> • <a href="#installation">Installation</a> • <a href="#command-line-completion">Command-line completion</a> • <a href="#man-documentation">Man documentation</a> • <a href="#faq">FAQ</a> • <a href="#usage">Usage</a> • <a href="#ci-status">CI Status</a> • <a href="#contributing">Contributing</a> • <a href="#thanks">Thanks</a> • <a href="#license">License</a></p>

<br/>

Expand Down Expand Up @@ -144,7 +144,7 @@ Examples
Show info about PostMessageParameters struct
```
### Build Status
### CI Status
| Branch | Status |
|--------|--------|
Expand Down
56 changes: 32 additions & 24 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ import (
"github.com/essentialkaos/ek/v12/usage/man"
"github.com/essentialkaos/ek/v12/usage/update"

"github.com/essentialkaos/aligo/v2/cli/i18n"
"github.com/essentialkaos/aligo/v2/inspect"
)

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

// App info
const (
APP = "aligo"
VER = "2.1.3"
DESC = "Utility for viewing and checking Go struct alignment"
APP = "aligo"
VER = "2.2.0"
)

// Constants with options names
Expand Down Expand Up @@ -89,7 +89,7 @@ func Run(gitRev string, gomod []byte) {
args, errs := options.Parse(optMap)

if !errs.IsEmpty() {
terminal.Error("Options parsing errors:")
terminal.Error(i18n.UI.ERRORS.OPTION_PARSING.Add("", ":"))
terminal.Error(errs.String())
os.Exit(1)
}
Expand All @@ -106,9 +106,11 @@ func Run(gitRev string, gomod []byte) {
genAbout(gitRev).Print(options.GetS(OPT_VER))
os.Exit(0)
case options.GetB(OPT_VERB_VER):
support.Collect(APP, VER).WithRevision(gitRev).
support.Collect(APP, VER).
WithRevision(gitRev).
WithDeps(deps.Extract(gomod)).
WithApps(apps.Golang()).Print()
WithApps(apps.Golang()).
Print()
os.Exit(0)
case options.GetB(OPT_HELP) || len(args) < 2:
genUsage().Print()
Expand Down Expand Up @@ -140,6 +142,8 @@ func preConfigureUI() {
default:
colorTagApp, colorTagVer = "{*}{&}{c}", "{c}"
}

i18n.SetLanguage()
}

// configureUI configures user interface
Expand All @@ -163,7 +167,7 @@ func prepare() error {
inspect.Sizes = types.SizesFor("gc", arch)

if inspect.Sizes == nil {
return fmt.Errorf("Unknown arch %s", arch)
return fmt.Errorf(i18n.UI.ERRORS.UNKNOWN_ARCH.String(), arch)
}

return nil
Expand Down Expand Up @@ -213,7 +217,7 @@ func process(args options.Arguments) (error, bool) {
}

default:
return fmt.Errorf("Command %s is unsupported", cmd), false
return fmt.Errorf(i18n.UI.ERRORS.UNSUPPORTED_COMMAND.String(), cmd), false
}

return nil, true
Expand Down Expand Up @@ -246,40 +250,44 @@ func printMan() {

// genUsage generates usage info
func genUsage() *usage.Info {
info := usage.NewInfo("", "package…")
info := usage.NewInfo("", i18n.UI.USAGE.ARGUMENTS.String())

info.AppNameColorTag = colorTagApp

info.AddCommand("check", "Check package for alignment problems")
info.AddCommand("view", "Print alignment info for all structs")
info.AddCommand("check", i18n.UI.USAGE.COMMANDS.CHECK.String())
info.AddCommand("view", i18n.UI.USAGE.COMMANDS.VIEW.String())

info.AddOption(OPT_ARCH, "Architecture name", "name")
info.AddOption(OPT_STRUCT, "Print info only about struct with given name", "name")
info.AddOption(OPT_TAGS, "Build tags {s-}(mergeble){!}", "tag…")
info.AddOption(OPT_PAGER, "Use pager for long output")
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
info.AddOption(OPT_HELP, "Show this help message")
info.AddOption(OPT_VER, "Show version")
info.AddOption(OPT_ARCH, i18n.UI.USAGE.OPTIONS.ARCH.String(), i18n.UI.USAGE.OPTIONS.ARCH_VAL.String())
info.AddOption(OPT_STRUCT, i18n.UI.USAGE.OPTIONS.STRUCT.String(), i18n.UI.USAGE.OPTIONS.STRUCT_VAL.String())
info.AddOption(OPT_TAGS, i18n.UI.USAGE.OPTIONS.TAGS.String(), i18n.UI.USAGE.OPTIONS.TAGS_VAL.String())
info.AddOption(OPT_PAGER, i18n.UI.USAGE.OPTIONS.PAGER.String())
info.AddOption(OPT_NO_COLOR, i18n.UI.USAGE.OPTIONS.NO_COLOR.String())
info.AddOption(OPT_HELP, i18n.UI.USAGE.OPTIONS.HELP.String())
info.AddOption(OPT_VER, i18n.UI.USAGE.OPTIONS.VER.String())

info.AddExample(
"view .", "Show info about all structs in current package",
"view .",
i18n.UI.USAGE.EXAMPLES.EXAMPLE_1.String(),
)

info.AddExample(
"check .", "Check current package",
"check .",
i18n.UI.USAGE.EXAMPLES.EXAMPLE_2.String(),
)

info.AddExample(
"check ./...", "Check current package and all sub-packages",
"check ./...",
i18n.UI.USAGE.EXAMPLES.EXAMPLE_3.String(),
)

info.AddExample(
"--tags tag1,tag2,tag3 check ./...", "Check current package and all sub-packages with custom build tags",
"--tags tag1,tag2,tag3 check ./...",
i18n.UI.USAGE.EXAMPLES.EXAMPLE_4.String(),
)

info.AddExample(
"-s PostMessageParameters view .",
"Show info about PostMessageParameters struct",
i18n.UI.USAGE.EXAMPLES.EXAMPLE_5.String(),
)

return info
Expand All @@ -290,7 +298,7 @@ func genAbout(gitRev string) *usage.About {
about := &usage.About{
App: APP,
Version: VER,
Desc: DESC,
Desc: i18n.UI.USAGE.DESC.String(),
Year: 2009,
Owner: "ESSENTIAL KAOS",

Expand Down
Loading

0 comments on commit f190298

Please sign in to comment.