Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ changelog:

brews:
- name: unique
alternative_names:
- unique@{{ .Version }}
- unique@{{ .Major }}.{{ .Minor }}
- unique@{{ .Major }}
description: "Outputs the unique lines of its input"
homepage: "https://github.com/ro-tex/unique"
license: "MIT"
folder: Formula
directory: Formula
url_template: "https://github.com/ro-tex/unique/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
commit_author:
name: goreleaserbot
Expand Down
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
golang 1.22.2
goreleaser 1.25.1
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `--version` command that outputs version and commit hash.

### Changed

- Switched to using v2 of xxhash library.
Expand Down
16 changes: 14 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# https://github.com/casey/just

build:
goreleaser build --clean --snapshot

buildWithVersion version commitHash:
go build -ldflags "-X main.version={{version}} -X main.commit={{commitHash}}" .

release version:
@[[ "{{version}}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] # ensure semantic versioning
@echo "Creating a release for version {{version}}:"
git tag -a {{version}} -m "{{version}}"
git push origin {{version}}
goreleaser release --clean

sign-last-commit:
git commit --amend --no-edit -S
sign-last-commit:
git commit --amend --no-edit -S

changeset:
npx changeset

hash:
git rev-parse --short HEAD
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const (
defaultLineLengthLimit = 100 * 1024 * 1024 // 100 MiB
)

var (
// These variables are set at build time by GoReleaser. See https://goreleaser.com/cookbooks/using-main.version/
version = "dev"
commit = "none"
)

// readFile opens the given file for reading and returns a reader and a closing function.
func readFile(path string, lineLimit int) (r *bufio.Reader, closeFn func() error, err error) {
if path == "" {
Expand Down Expand Up @@ -104,11 +110,19 @@ func main() {
var filePath string
var trim bool
var lineLengthLimit int
var versionFlag bool
flag.StringVar(&filePath, "f", "", "path to the file to process")
flag.BoolVar(&trim, "t", false, "trim whitespace from each line (default false)")
flag.IntVar(&lineLengthLimit, "ll", defaultLineLengthLimit, "limit the length of each line being processed, ignoring any data beyond that length (values under 16 are ignored)")
flag.BoolVar(&versionFlag, "version", false, "print the version")
flag.Parse()

// Print the version and exit.
if versionFlag {
fmt.Println(version, commit)
return
}

reader, closeFn, err := readFile(filePath, lineLengthLimit)
if err != nil {
log.Fatalf("Failed to read from file '%s'. Error: %s\n", filePath, err.Error())
Expand Down
21 changes: 21 additions & 0 deletions radicle_init.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
inovakov unique % rad init 35ms

Initializing radicle 👾 repository in /Users/inovakov/source/unique..

✓ Name unique
✓ Description Reads a file and outputs all unique lines.
✓ Default branch main
✓ Visibility public
✓ Repository unique created.

Your Repository ID (RID) is rad:z4MMHetnbTkfuZtc5jMapMavrmQth.
You can show it any time by running `rad .` from this directory.

✓ Repository successfully synced to 1 node(s).

Your repository has been synced to the network and is now discoverable by peers.
View it in your browser at:

https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z4MMHetnbTkfuZtc5jMapMavrmQth

To push changes, run `git push rad main`.