diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..0e43240 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,70 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +project_name: gzipdate +env: + - GO111MODULE=on +before: + hooks: + - go mod tidy +builds: +- env: + - CGO_ENABLED=0 + goos: + - darwin + - freebsd + - linux + - netbsd + - openbsd + - windows + ignore: + - goos: darwin + goarch: 386 + ldflags: + - -s -w + main: ./main.go +archives: + - files: + - CHANGELOG.md + - LICENSE + - README.md + format_overrides: + - goos: windows + format: zip + replacements: + 386: i386 + amd64: x86_64 + darwin: macos + # darwin: macOS + # freebsd: FreeBSD + # linux: Linux + # netbsd: NetBSD + # openbsd: OpenBSD + # gzipdate: GzipDate + # windows: Windows + wrap_in_directory: true +nfpms: + # note that this is an array of nfpm configs + - formats: + - deb + - rpm + # ID of the nfpm config, must be unique. + # Defaults to "default". + id: gzipdate + homepage: "https://github.com/runeimp/gzipdate" + license: MIT + replacements: + 386: i386 + amd64: x86_64 + darwin: macos +checksum: + name_template: 'checksums.txt' +# signs: +# - artifacts: checksum +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..960f637 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +ChangeLog: +========== + +v1.0.0 +------ + +Initial release + +* Added all initially planned features + diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..468f376 --- /dev/null +++ b/Justfile @@ -0,0 +1,71 @@ +PROJECT_NAME := "GzipDate" + +alias arc := archive + +@_default: + just _term-wipe + just --list + +# Archive GoReleaser dist +archive: + #!/bin/sh + just _term-wipe + tag="$(git tag --points-at master)" + app="{{PROJECT_NAME}}" + arc="${app}_${tag}" + + # echo "app = '${app}'" + # echo "tag = '${tag}'" + # echo "arc = '${arc}'" + if [ -e dist ]; then + echo "Move dist -> distro/${arc}" + mv dist "distro/${arc}" + + # echo "cd distro" + cd distro + + printf "pwd = " + pwd + + ls -Alh + else + echo "dist directory not found for archiving" + fi + +# Build and install app +build: + @just _term-wipe + go build -o gzipdate main.go + mv gzipdate "${GOBIN}/" + @# go install main.go + + +# Build distro +distro: + #!/bin/sh + goreleaser + just archive + + +# Run code +run +args='': + @just _term-wipe + go run main.go {{args}} + + +_term-wipe: + #!/bin/sh + if [[ ${#VISUAL_STUDIO_CODE} -gt 0 ]]; then + clear + elif [[ ${KITTY_WINDOW_ID} -gt 0 ]] || [[ ${#TMUX} -gt 0 ]] || [[ "${TERM_PROGRAM}" = 'vscode' ]]; then + printf '\033c' + elif [[ "$(uname)" == 'Darwin' ]] || [[ "${TERM_PROGRAM}" = 'Apple_Terminal' ]] || [[ "${TERM_PROGRAM}" = 'iTerm.app' ]]; then + osascript -e 'tell application "System Events" to keystroke "k" using command down' + elif [[ -x "$(which tput)" ]]; then + tput reset + elif [[ -x "$(which reset)" ]]; then + reset + else + clear + fi + diff --git a/README.md b/README.md index 8b3fb91..4401f90 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Features * Does not delete source files by default. Though they can be automatically deleted with a command line switch. * Always uses maximum compression when creating archives * 100% compatible with gzip and gunzip tools +* Written in Go so it's easy to cross-compile binaries for many platforms Rational diff --git a/main.go b/main.go index cc419ce..3601092 100644 --- a/main.go +++ b/main.go @@ -18,9 +18,15 @@ import ( const ( AppName = "GzipDate" AppVersion = "1.0.0" - argDeleteUsage = "Delete the source file after successful processing" - argHelpUsage = "Display this help info" - argVersionUsage = "Display this apps version number" + cliDeleteUsage = "Delete the source file after successful processing" + cliHelpUsage = "Display this help info" + cliVersionUsage = "Display this apps version number" + cliUsageHeader = `%s + +USAGE: gzipdate [OPTIONS] [FILENAMES] + +OPTIONS: +` ) /* @@ -44,12 +50,12 @@ func main() { // Bespoke CLI Handler because flags is lame for _, arg := range os.Args[1:] { switch arg { - case "-d", "-del", "-delete": + case "-d", "-del", "-delete", "--delete": deleteSource = true - case "-h", "-help": + case "-h", "-help", "--help": helpOutput() os.Exit(0) - case "-v", "-ver", "-version": + case "-v", "-ver", "-version", "--version": fmt.Println(AppLabel) os.Exit(0) default: @@ -192,15 +198,10 @@ func gzipEncode(filename string) error { } func helpOutput() { - // flag.Usage() - // fmt.Println("----") - fmt.Printf("USAGE: gzipdate [OPTIONS] FILENAMES\n\nOPTIONS:\n") - // flag.PrintDefaults() - // fmt.Println() - - fmt.Printf(" -d | -del | -delete %s\n", argDeleteUsage) - fmt.Printf(" -h | -help %s\n", argHelpUsage) - fmt.Printf(" -v | -ver | -version %s\n", argVersionUsage) + fmt.Printf(cliUsageHeader, AppLabel) + fmt.Printf(" -d | -del | -delete %s\n", cliDeleteUsage) + fmt.Printf(" -h | -help %s\n", cliHelpUsage) + fmt.Printf(" -v | -ver | -version %s\n", cliVersionUsage) fmt.Println() fmt.Printf("Options may be interspersed with file names if so desired.\nThey are not position dependent.\n\n") }