-
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 09d5a1c
Showing
14 changed files
with
529 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,39 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.19' | ||
cache: false | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.54 | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Install dependencies | ||
run: go get . | ||
- name: Build | ||
run: make 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,32 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
# run only against tags | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+*" | ||
|
||
permissions: | ||
contents: write | ||
# packages: write | ||
# issues: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.19 | ||
- run: go mod tidy | ||
|
||
- uses: goreleaser/goreleaser-action@v2 | ||
if: success() && startsWith(github.ref, 'refs/tags/') | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 @@ | ||
dist | ||
bin | ||
dist/ |
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,26 @@ | ||
# Refer to golangci-lint's example config file for more options and information: | ||
# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml | ||
|
||
run: | ||
timeout: 5m | ||
modules-download-mode: readonly | ||
|
||
linters: | ||
enable: | ||
- errcheck | ||
- goimports | ||
- revive | ||
- govet | ||
- staticcheck | ||
|
||
linters-settings: | ||
revive: | ||
rules: | ||
- name: unexported-return | ||
disabled: true | ||
|
||
|
||
issues: | ||
exclude-use-default: false | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 |
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 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
|
||
# The lines bellow are called `modelines`. See `:help modeline` | ||
# Feel free to remove those if you don't want/need to use them. | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
||
|
||
project_name: countdown | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
|
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,9 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2023 Yofan Niki | ||
|
||
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,21 @@ | ||
.DIST_FOLDER := build | ||
|
||
fmt: | ||
go fmt ./... | ||
.PHONY:fmt | ||
|
||
lint: fmt | ||
golangci-lint run ./... | ||
.PHONY:lint | ||
|
||
vet: fmt | ||
go vet ./... | ||
.PHONY:vet | ||
|
||
build: vet | ||
go build -o bin/countdown . | ||
.PHONY:build | ||
|
||
release: vet | ||
goreleaser release --snapshot --clean | ||
.PHONY:release |
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,19 @@ | ||
# countdown | ||
|
||
`countdown` is a simple timer that runs from the command line. | ||
|
||
# Usage | ||
|
||
``` | ||
Usage of countdown: | ||
countdown -d duration | ||
The flags are: | ||
-d | ||
The duration of the timer as a string of unsigned | ||
decimal numbers, each with optional fraction and | ||
a unit suffix, such as "300ms", "1.5h" or "2h45m". | ||
Expected time units are "s", "m", "h". | ||
``` |
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,24 @@ | ||
package font | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/charmbracelet/lipgloss" | ||
) | ||
|
||
// DrawChar returns the argument character in bigger size. | ||
func DrawChar(c rune) string { | ||
b := strings.Builder{} | ||
for _, row := range smallFonts[c] { | ||
for _, char := range row { | ||
s := lipgloss.NewStyle().SetString(" ") | ||
if char == rune('#') { | ||
s = s.Background(lipgloss.Color("#ffd670")) | ||
} | ||
b.WriteString(s.String()) | ||
} | ||
b.WriteRune('\n') | ||
} | ||
|
||
return b.String() | ||
} |
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,124 @@ | ||
package font | ||
|
||
import "strings" | ||
|
||
// Define ASCII art representations of various characters. | ||
var colon = ` | ||
.. | ||
#. | ||
.. | ||
#. | ||
.. | ||
` | ||
|
||
var zero = ` | ||
######. | ||
#....#. | ||
#....#. | ||
#....#. | ||
######. | ||
` | ||
|
||
var one = ` | ||
.....#. | ||
.....#. | ||
.....#. | ||
.....#. | ||
.....#. | ||
` | ||
|
||
var two = ` | ||
######. | ||
.....#. | ||
######. | ||
#...... | ||
######. | ||
` | ||
|
||
var three = ` | ||
######. | ||
.....#. | ||
...###. | ||
.....#. | ||
######. | ||
` | ||
|
||
var four = ` | ||
#...... | ||
#...... | ||
#...#.. | ||
######. | ||
....#.. | ||
` | ||
|
||
var five = ` | ||
######. | ||
#...... | ||
######. | ||
.....#. | ||
######. | ||
` | ||
|
||
var six = ` | ||
######. | ||
#...... | ||
######. | ||
#....#. | ||
######. | ||
` | ||
|
||
var seven = ` | ||
######. | ||
.....#. | ||
.....#. | ||
.....#. | ||
.....#. | ||
` | ||
|
||
var height = ` | ||
######. | ||
#....#. | ||
######. | ||
#....#. | ||
######. | ||
` | ||
|
||
var nine = ` | ||
######. | ||
#....#. | ||
######. | ||
.....#. | ||
######. | ||
` | ||
|
||
// smallFonts defines the font used to display characters on the terminal. | ||
var smallFonts = map[rune][][]rune{ | ||
':': asArray(colon), | ||
'1': asArray(one), | ||
'2': asArray(two), | ||
'3': asArray(three), | ||
'4': asArray(four), | ||
'5': asArray(five), | ||
'6': asArray(six), | ||
'7': asArray(seven), | ||
'8': asArray(height), | ||
'9': asArray(nine), | ||
'0': asArray(zero), | ||
} | ||
|
||
// asArray converts a string representation of characters to a 2D slice of runes. | ||
func asArray(chars string) [][]rune { | ||
result := [][]rune{} | ||
line := []rune{} | ||
str := strings.TrimPrefix(chars, "\n") | ||
|
||
for _, c := range str { | ||
if c == '\n' { | ||
result = append(result, line) | ||
line = []rune{} | ||
} else { | ||
line = append(line, c) | ||
} | ||
} | ||
return result | ||
} |
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,25 @@ | ||
module github.com/yofan2408/countdown | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/charmbracelet/bubbletea v0.23.1 | ||
github.com/charmbracelet/lipgloss v0.6.0 | ||
) | ||
|
||
require ( | ||
github.com/aymanbagabas/go-osc52 v1.0.3 // indirect | ||
github.com/containerd/console v1.0.3 // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/mattn/go-isatty v0.0.16 // indirect | ||
github.com/mattn/go-localereader v0.0.1 // indirect | ||
github.com/mattn/go-runewidth v0.0.14 // indirect | ||
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect | ||
github.com/muesli/cancelreader v0.2.2 // indirect | ||
github.com/muesli/reflow v0.3.0 // indirect | ||
github.com/muesli/termenv v0.13.0 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect | ||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
) |
Oops, something went wrong.