-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5759700
Showing
12 changed files
with
773 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
*.swp | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
GOCMD := env GO111MODULE=on go | ||
GOMOD := $(GOCMD) mod | ||
GOBUILD := $(GOCMD) build | ||
GOINSTALL := $(GOCMD) install | ||
GOCLEAN := $(GOCMD) clean | ||
GOTEST := $(GOCMD) test | ||
GOGET := $(GOCMD) get | ||
NAME := dango | ||
CURRENT := $(shell pwd) | ||
BUILDDIR := ./build | ||
BINDIR := $(BUILDDIR)/bin | ||
PKGDIR := $(BUILDDIR)/pkg | ||
DISTDIR := $(BUILDDIR)/dist | ||
|
||
VERSION := $(shell git describe --tags --abbrev=0) | ||
LDFLAGS := -X 'main.version=$(VERSION)' | ||
GOXOSARCH := "darwin/amd64 darwin/arm64 windows/386 windows/amd64 linux/386 linux/amd64" | ||
GOXOUTPUT := "$(PKGDIR)/$(NAME)_{{.OS}}_{{.Arch}}/{{.Dir}}" | ||
|
||
export GO111MODULE=on | ||
|
||
.PHONY: deps | ||
## Install dependencies | ||
deps: | ||
$(GOMOD) download | ||
|
||
.PHONY: devel-deps | ||
## Install dependencies for develop | ||
devel-deps: deps | ||
sh -c '\ | ||
tmpdir=$$(mktemp -d); \ | ||
cd $$tmpdir; \ | ||
$(GOGET) \ | ||
golang.org/x/tools/cmd/goimports \ | ||
golang.org/x/lint/golint \ | ||
github.com/Songmu/make2help/cmd/make2help \ | ||
github.com/mitchellh/gox \ | ||
github.com/tcnksm/ghr; \ | ||
rm -rf $$tmpdir' | ||
|
||
.PHONY: build | ||
## Build binaries | ||
build: deps | ||
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BINDIR)/$(NAME) . | ||
|
||
.PHONY: cross-build | ||
## Cross build binaries | ||
cross-build: | ||
rm -rf $(PKGDIR) | ||
gox -osarch=$(GOXOSARCH) -ldflags "$(LDFLAGS)" -output=$(GOXOUTPUT) . | ||
|
||
.PHONY: package | ||
## Make package | ||
package: cross-build | ||
rm -rf $(DISTDIR) | ||
mkdir $(DISTDIR) | ||
pushd $(PKGDIR) > /dev/null && \ | ||
for P in `ls | xargs basename`; do zip -r $(CURRENT)/$(DISTDIR)/$$P.zip $$P; done && \ | ||
popd > /dev/null | ||
|
||
.PHONY: release | ||
## Release package to Github | ||
release: package | ||
ghr $(VERSION) $(DISTDIR) | ||
|
||
.PHONY: test | ||
## Run tests | ||
test: deps | ||
$(GOTEST) -v ./... | ||
|
||
.PHONY: lint | ||
## Lint | ||
lint: devel-deps | ||
go vet ./... | ||
golint -set_exit_status ./... | ||
|
||
.PHONY: fmt | ||
## Format source codes | ||
fmt: deps | ||
find . -name "*.go" -not -path "./vendor/*" | xargs goimports -w | ||
|
||
.PHONY: clean | ||
clean: | ||
$(GOCLEAN) | ||
rm -rf $(BUILDDIR) | ||
|
||
.PHONY: help | ||
## Show help | ||
help: | ||
@make2help $(MAKEFILE_LIST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
[English](README.md) | [日本語](README_ja.md) | ||
|
||
# 🍡 dango | ||
|
||
🍡`dango` is a program that concatenates and splits standard input. | ||
|
||
## Description | ||
|
||
`dango` concatenates and splits the standard input. | ||
|
||
`dango` concatenates and splits standard input by bytes, characters, words, or line breaks. | ||
`dango` reads the standard input and whenever it reads a specified number of elements, it puts them on a line and prints them to the standard output. | ||
|
||
## Usage | ||
|
||
``` | ||
$ cat << EOF | dango | ||
━ | ||
🟠 | ||
🟡 | ||
🟢 | ||
━ | ||
EOF | ||
━🟠🟡🟢━ | ||
``` | ||
|
||
Concatenate or split by number of bytes. | ||
|
||
``` | ||
$ echo 'Hello World!' | dango -b -n 1 | ||
H | ||
e | ||
l | ||
l | ||
o | ||
W | ||
o | ||
r | ||
l | ||
d | ||
! | ||
$ echo 'Hello World!' | dango -b -n 5 | ||
Hello | ||
Worl | ||
d! | ||
``` | ||
|
||
Concatenate or split by number of characters. | ||
|
||
``` | ||
$ echo '花より団子' | dango -c -n 1 | ||
花 | ||
よ | ||
り | ||
団 | ||
子 | ||
$ echo '花より団子' | dango -c -n 3 | ||
花より | ||
団子 | ||
``` | ||
|
||
Concatenate or split by word count. | ||
|
||
``` | ||
$ echo 'Hello World!' | dango -w -n 1 | ||
Hello | ||
World! | ||
$ echo 'Hello World!' | dango -w | ||
HelloWorld! | ||
``` | ||
|
||
Concatenate or split by the number of line breaks. | ||
|
||
``` | ||
$ cat << EOF | dango -l -n 1 | ||
Hello | ||
World! | ||
EOF | ||
Hello | ||
World! | ||
$ cat << EOF | dango -l | ||
Hello | ||
World | ||
! | ||
EOF | ||
HelloWorld! | ||
``` | ||
|
||
Specify a delimiter to concatenate or split. | ||
|
||
``` | ||
$ echo 'abcdefg' | dango -c -d ' ' | ||
a b c d e f g | ||
$ cat << EOF | dango -d ' ' | ||
Hello | ||
World! | ||
EOF | ||
Hello World! | ||
``` | ||
|
||
Show help. | ||
|
||
``` | ||
$ dango -help | ||
# ... | ||
``` | ||
|
||
## Installation | ||
|
||
### Developer | ||
|
||
Go 1.16 or later. | ||
|
||
``` | ||
$ go install github.com/ebc-2in2crc/dango@latest | ||
``` | ||
|
||
Go 1.15. | ||
|
||
``` | ||
$ go get github.com/ebc-2in2crc/dango/... | ||
``` | ||
|
||
### User | ||
|
||
Download from the following url. | ||
|
||
- [https://github.com/ebc-2in2crc/dango/releases](https://github.com/ebc-2in2crc/dango/releases) | ||
|
||
## Contribution | ||
|
||
1. Fork this repository | ||
2. Create your feature branch (git checkout -b my-new-feature) | ||
3. Commit your changes (git commit -am 'Add some feature') | ||
4. Rebase your local changes against the master branch | ||
5. Run test suite with the `make test` command and confirm that it passes | ||
6. Run `make fmt` | ||
7. Create new Pull Request | ||
|
||
## License | ||
|
||
[MIT](https://github.com/ebc-2in2crc/wareki/blob/master/LICENSE) | ||
|
||
## Author | ||
|
||
[ebc-2in2crc](https://github.com/ebc-2in2crc) |
Oops, something went wrong.