diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fc51337..d0ad1de 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -14,6 +14,12 @@ updates: - "andyone" reviewers: - "andyone" + groups: + all: + applies-to: version-updates + update-types: + - "minor" + - "patch" - package-ecosystem: "github-actions" directory: "/" diff --git a/.github/images/card.svg b/.github/images/card.svg new file mode 100644 index 0000000..47bfcf7 --- /dev/null +++ b/.github/images/card.svg @@ -0,0 +1,5 @@ + diff --git a/.github/images/license.svg b/.github/images/license.svg new file mode 100644 index 0000000..8990e77 --- /dev/null +++ b/.github/images/license.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.github/images/usage.svg b/.github/images/usage.svg new file mode 100644 index 0000000..cdf4be9 --- /dev/null +++ b/.github/images/usage.svg @@ -0,0 +1,84 @@ + + diff --git a/Makefile b/Makefile index 248c9e1..b4d3955 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,40 @@ ################################################################################ -# This Makefile generated by GoMakeGen 2.3.0 using next command: +# This Makefile generated by GoMakeGen 3.0.2 using next command: # gomakegen --mod . # # More info: https://kaos.sh/gomakegen ################################################################################ -export GO111MODULE=on - ifdef VERBOSE ## Print verbose information (Flag) VERBOSE_FLAG = -v endif -COMPAT ?= 1.18 +COMPAT ?= 1.19 MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD) ################################################################################ .DEFAULT_GOAL := help -.PHONY = fmt vet all clean deps update init vendor mod-init mod-update mod-download mod-vendor help +.PHONY = fmt vet all install uninstall clean deps update init vendor mod-init mod-update mod-download mod-vendor help ################################################################################ all: icecli ## Build all binaries icecli: - go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" icecli.go + @echo "[36;1mBuilding icecli…[0m" + @go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" icecli.go install: ## Install all binaries - cp icecli /usr/bin/icecli + @echo "[36;1mInstalling binaries…[0m" + @cp icecli /usr/bin/icecli uninstall: ## Uninstall all binaries - rm -f /usr/bin/icecli + @echo "[36;1mRemoving installed binaries…[0m" + @rm -f /usr/bin/icecli init: mod-init ## Initialize new module @@ -44,57 +45,70 @@ update: mod-update ## Update dependencies to the latest versions vendor: mod-vendor ## Make vendored copy of dependencies mod-init: + @echo "[37m[1/2][0m [36;1mModules initialization…[0m" ifdef MODULE_PATH ## Module path for initialization (String) - go mod init $(MODULE_PATH) + @go mod init $(MODULE_PATH) else - go mod init + @go mod init endif + @echo "[37m[2/2][0m [36;1mDependencies cleanup…[0m" ifdef COMPAT ## Compatible Go version (String) - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif mod-update: + @echo "[37m[1/4][0m [36;1mUpdating dependencies…[0m" ifdef UPDATE_ALL ## Update all dependencies (Flag) - go get -u $(VERBOSE_FLAG) all + @go get -u $(VERBOSE_FLAG) all else - go get -u $(VERBOSE_FLAG) ./... + @go get -u $(VERBOSE_FLAG) ./... endif + @echo "[37m[2/4][0m [36;1mStripping toolchain info…[0m" + @grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || : + + @echo "[37m[3/4][0m [36;1mDependencies cleanup…[0m" ifdef COMPAT - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif - test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : + @echo "[37m[4/4][0m [36;1mUpdating vendored dependencies…[0m" + @test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : mod-download: - go mod download + @echo "[36;1mDownloading dependencies…[0m" + @go mod download mod-vendor: - rm -rf vendor && go mod vendor $(VERBOSE_FLAG) + @echo "[36;1mVendoring dependencies…[0m" + @rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : fmt: ## Format source code with gofmt - find . -name "*.go" -exec gofmt -s -w {} \; + @echo "[36;1mFormatting sources…[0m" + @find . -name "*.go" -exec gofmt -s -w {} \; vet: ## Runs 'go vet' over sources - go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... + @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 - rm -f icecli + @echo "[36;1mRemoving built binaries…[0m" + @rm -f icecli help: ## Show this info @echo -e '\n\033[1mTargets:\033[0m\n' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ - | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-14s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-9s\033[0m %s\n", $$1, $$2}' @echo -e '\n\033[1mVariables:\033[0m\n' @grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \ | sed 's/ifdef //' \ - | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index 8ed0ec8..f14233e 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -
+ -Installation • Command-line completion • Usage • Build Status • Contributing • License
+Installation • Command-line completion • Usage • CI Status • Contributing • License
@@ -18,7 +18,7 @@ #### From source -To build the `icecli` from scratch, make sure you have a working Go 1.18+ workspace (_[instructions](https://go.dev/doc/install)_), then: +To build the `icecli` from scratch, make sure you have a working Go 1.21+ workspace (_[instructions](https://go.dev/doc/install)_), then: ```bash go install github.com/essentialkaos/icecli@latest @@ -55,43 +55,9 @@ sudo icecli --completion=fish 1> /usr/share/fish/vendor_completions.d/icecli.fis ### Usage -``` -Usage: icecli {options} {command} arguments… - -Commands - - stats Show Icecast statistics - list-mounts List mount points - list-clients mount List clients - move-clients from-mount to-mount Move clients between mounts - update-meta mount artist title Update meta for mount - kill-client mount client-id Kill client connection - kill-source mount Kill source connection - help command Show detailed info about command usage - -Options - - --host, -H host URL of Icecast instance (default: http://127.0.0.1:8000) - --user, -U username Admin username (default: admin) - --password, -P password Admin password (default: hackme) - --no-color, -nc Disable colors in output - --help, -h Show this help message - --version, -v Show version - -Examples - - icecli stats -H 127.0.0.1:10000 - Show stats for server on 127.0.0.1:10000 - - icecli kill-client -P mYsUpPaPaSs /stream3 361 - Detach client with ID 361 from /stream3 - - icecli list-clients -H 127.0.0.1:10000 -U super_admin -P mYsUpPaPaSs /stream3 - List clients on /stream3 - -``` + -### Build Status +### CI Status | Branch | Status | |--------|--------| diff --git a/cli/cli.go b/cli/cli.go index a60aa18..4ff6078 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -21,6 +21,7 @@ import ( "github.com/essentialkaos/ek/v12/support" "github.com/essentialkaos/ek/v12/support/deps" "github.com/essentialkaos/ek/v12/support/pkgs" + "github.com/essentialkaos/ek/v12/terminal" "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/timeutil" "github.com/essentialkaos/ek/v12/usage" @@ -38,7 +39,7 @@ import ( const ( APP = "icecli" DESC = "Icecast CLI" - VER = "1.1.0" + VER = "1.1.1" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -100,13 +101,9 @@ func Run(gitRev string, gomod []byte) { args, errs := options.Parse(optMap) - if len(errs) != 0 { - printError("Options parsing errors:") - - for _, err := range errs { - printError(" %v", err) - } - + if !errs.IsEmpty() { + terminal.Error("Options parsing errors:") + terminal.Error(errs.String()) os.Exit(1) } @@ -215,7 +212,7 @@ func execCommand(args options.Arguments) { checkForRequiredArgs(args, 1) killSource(args.Get(1).String()) default: - printError("Unknown or unsupported command %q", cmd) + terminal.Error("Unknown or unsupported command %q", cmd) os.Exit(1) } } @@ -524,14 +521,9 @@ func checkForRequiredArgs(args options.Arguments, required int) { ) } -// printError prints error message to console -func printError(f string, a ...interface{}) { - fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) -} - // printErrorExit prints error message to console and exit with error code func printErrorExit(f string, a ...interface{}) { - fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) + terminal.Error(f, a...) os.Exit(1) } @@ -676,12 +668,7 @@ func printCompletion() int { // printMan prints man page func printMan() { - fmt.Println( - man.Generate( - genUsage(), - genAbout(""), - ), - ) + fmt.Println(man.Generate(genUsage(), genAbout(""))) } // genUsage generates usage info diff --git a/go.mod b/go.mod index 6237b1b..e38bad0 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,15 @@ module github.com/essentialkaos/icecli go 1.18 require ( - github.com/essentialkaos/ek/v12 v12.113.1 - github.com/essentialkaos/go-icecast/v2 v2.0.6 + github.com/essentialkaos/ek/v12 v12.127.0 + github.com/essentialkaos/go-icecast/v2 v2.0.8 ) require ( github.com/andybalholm/brotli v1.1.0 // indirect - github.com/essentialkaos/depsy v1.1.0 // indirect - github.com/klauspost/compress v1.17.7 // indirect + github.com/essentialkaos/depsy v1.3.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.52.0 // indirect - golang.org/x/sys v0.18.0 // indirect + github.com/valyala/fasthttp v1.55.0 // indirect + golang.org/x/sys v0.21.0 // indirect ) diff --git a/go.sum b/go.sum index ac7370c..11ee2da 100644 --- a/go.sum +++ b/go.sum @@ -1,20 +1,20 @@ github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= -github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.113.1 h1:3opV9dwRpIQq1fqg5mkaSEt6ogECL4VLzrH/829qeYg= -github.com/essentialkaos/ek/v12 v12.113.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= -github.com/essentialkaos/go-icecast/v2 v2.0.6 h1:QqMwPT+TNN6R5xaQKsLINubtvdDg8LvcEhpynn3TVkI= -github.com/essentialkaos/go-icecast/v2 v2.0.6/go.mod h1:EEzBSggEHWafABzwhKCRqFrxEPf1x2OHcu863EbD4/0= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/essentialkaos/depsy v1.3.0 h1:CN7bRgBU2jGTHSkg/Sh38eDUn7cvmaTp2sxFt2HpFeU= +github.com/essentialkaos/depsy v1.3.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= +github.com/essentialkaos/ek/v12 v12.127.0 h1:fU5A+QbIZ7NTq1K5jGVwAWwuLtBUhsIKuRWYT78hE+Q= +github.com/essentialkaos/ek/v12 v12.127.0/go.mod h1:71IJ7m82hgjrvWnhL+z0vIhguxz47/rfVma5/CeI5Fw= +github.com/essentialkaos/go-icecast/v2 v2.0.8 h1:N989ahL/Ap6FN1H51TF6el0mzfqhYt3MkwusDYZWd7c= +github.com/essentialkaos/go-icecast/v2 v2.0.8/go.mod h1:uuUP+dbp2G913OYeiVTwsg+EvImwVIahrtRM8yyElgg= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.52.0 h1:wqBQpxH71XW0e2g+Og4dzQM8pk34aFYlA1Ga8db7gU0= -github.com/valyala/fasthttp v1.52.0/go.mod h1:hf5C4QnVMkNXMspnsUlfM3WitlgYflyhHYoKol/szxQ= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +github.com/valyala/fasthttp v1.55.0 h1:Zkefzgt6a7+bVKHnu/YaYSOPfNYNisSVBo/unVCf8k8= +github.com/valyala/fasthttp v1.55.0/go.mod h1:NkY9JtkrpPKmgwV3HTaS2HWaJss9RSIsRVfcxxoHiOM= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=