Skip to content

Commit

Permalink
feat: initial commit 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
Madh93 committed Jul 13, 2023
0 parents commit b088d43
Show file tree
Hide file tree
Showing 38 changed files with 1,960 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
cmd = "/usr/bin/make install"
bin = "/usr/bin/true"
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
indent_style = tab
indent_size = 4

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
28 changes: 28 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2

- name: Set up Go
uses: actions/setup-go@v4.0.0
with:
go-version: '^1.20.5'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Binaries for programs and plugins
bin/
dist/
tmp/
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Config files
toffu.json
TODO.md

# Log files
*.log

# Environment Files
.env

# IDEs
.idea/
.vscode/
*.swp

# Generated by MacOS
.DS_Store
67 changes: 67 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

brews:
- name: toffu
homepage: "https://github.com/Madh93/toffu"
description: "Woffu presence from your terminal"
license: "MIT"
commit_msg_template: "feat({{ .ProjectName }}): Brew formula update to version {{ .Tag }}"
repository:
owner: Madh93
name: homebrew-tap

scoops:
- repository:
owner: Madh93
name: scoop-bucket
homepage: "https://github.com/Madh93/toffu"
description: "Woffu presence from your terminal"
license: "MIT"
commit_msg_template: "feat({{ .ProjectName }}): Scoop update to version {{ .Tag }}"

release:
github:
owner: Madh93
name: toffu
draft: true

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-mod-tidy
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
air 1.44.0
golang 1.20.5
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Miguel Hernández

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.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build #-race
GORUN=$(GOCMD) run
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
OUT=toffu

.PHONY: all clean test run build install update-dependencies

all: build
clean:
$(GOCLEAN) && rm -rf bin/$(OUT)
test:
$(GOTEST) ./...
run:
$(GORUN) main.go
build:
$(GOBUILD) -o bin/$(OUT) main.go
install: build
mkdir -p /usr/local/bin && cp bin/$(OUT) /usr/local/bin/$(OUT) && chmod +x /usr/local/bin/$(OUT)
update-dependencies:
$(GOCMD) get -u all && $(GOCMD) mod tidy
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Toffu

[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)

Toffu is a command-line interface (CLI) tool that enables users to manage their work schedule presence in [Woffu](https://www.woffu.com) directly from the terminal. With Toffu, users can conveniently interact with their Woffu account without the need to access the Woffu web interface.

<img alt="Toffu Demo" src="docs/gif/demo.gif"/>

<p align="center">
<a href="#installation">Installation</a> •
<a href="#usage">Usage</a> •
<a href="#useful-links">Useful Links</a> •
<a href="#license">License</a>
</p>

## Installation

### GNU/Linux or macOS

Via [Homebrew](https://brew.sh/):

```shell
brew install madh93/tap/toffu
```

### Windows

Via [Scoop](https://scoop.sh/):

```shell
scoop bucket add madh93 https://github.com/madh93/scoop-bucket.git
scoop install toffu
```

### From releases

Stable binaries for all platforms are available on the [releases page](https://github.com/Madh93/toffu/releases). To install, download the binary for your platform from "Assets", extract the downloaded file and place `toffu` into your `PATH`:

```shell
curl -L https://github.com/Madh93/toffu/releases/latest/download/toffu_$(uname -s)_$(uname -m).tar.gz | tar -xz -O toffu > /usr/local/bin/toffu
chmod +x /usr/local/bin/toffu
```

### Go

If you have Go installed:

```shell
go install github.com/Madh93/toffu@latest
```

### From source

Install Go if it is not already installed. You can download it from the official [website](https://golang.org/dl).

Clone the `toffu` repository to build and install the binary:

```shell
git clone https://github.com/Madh93/toffu && cd toffu && make install
```

## Usage

```shell
Toffu is a simple CLI to manage presence in Woffu from your terminal

Usage:
toffu [flags]
toffu [command]

Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
in On-demand clock-in
out On-demand clock-out
status Show current status
token Generate API token (Required the first time)

Flags:
-c, --config string config file for toffu
-d, --debug enable debug mode
-h, --help help for toffu
-v, --version version for toffu

Use "toffu [command] --help" for more information about a command.
```

### Generate a token

Before using Toffu, an API token needs to be generated for authentication. Keep in mind that the token expires after three months. After this time, you will need to generate a new token:

<img alt="Clock in" src="docs/gif/token.gif"/>

### Clock in

Start to work:

<img alt="Clock in" src="docs/gif/in.gif"/>

### Clock out

Check out or take a pause:

<img alt="Clock out" src="docs/gif/out.gif"/>

### Get status

Display the current work schedule status:

<img alt="Get status" src="docs/gif/status.gif"/>

## Useful Links

- [Woffu](https://www.woffu.com)
- [Woffu API](https://woffu.com/es/api)

## License

This project is licensed under the [MIT license](LICENSE).
24 changes: 24 additions & 0 deletions cmd/in.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"log"

"github.com/Madh93/toffu/internal/toffu"
"github.com/spf13/cobra"
)

var inCmd = &cobra.Command{
Use: "in",
Aliases: []string{"i"},
Short: "On-demand clock-in",
Run: func(cmd *cobra.Command, args []string) {
toffu := toffu.New()
if err := toffu.ClockIn(); err != nil {
log.Fatal(err)
}
},
}

func init() {
rootCmd.AddCommand(inCmd)
}
24 changes: 24 additions & 0 deletions cmd/out.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"log"

"github.com/Madh93/toffu/internal/toffu"
"github.com/spf13/cobra"
)

var outCmd = &cobra.Command{
Use: "out",
Aliases: []string{"o"},
Short: "On-demand clock-out",
Run: func(cmd *cobra.Command, args []string) {
toffu := toffu.New()
if err := toffu.ClockOut(); err != nil {
log.Fatal(err)
}
},
}

func init() {
rootCmd.AddCommand(outCmd)
}
Loading

0 comments on commit b088d43

Please sign in to comment.