hunter

package module
Version: v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 9 Imported by: 0

README

Horse Hunter (Go Implementation)

PkgGoDev

API

// get a single insult by arguments
fmt.Println(hunter.GetLine(hunter.LevelMax, hunter.TargetMale))

// create a worker
worker := hunter.NewWorkerDefault()

// get a single insult
fmt.Println(worker.GetLine())

// write an insult to clipboard
worker.WriteOnce()

// start the worker, continuously write insult to clipboard
worker.Start()

// stop the worker
worker.Stop()

// clean up the clipboard
hunter.Cleanup()

CLI

# Build
go build ./cmd/horse-hunter

# Run
$ horse-hunter -h
Usage of ./horse-hunter:
  -interval duration
        clipboard update interval (default 200ms)
  -level string
        insult level, [max | min | mix] (default "max")
  -target string
        insult target, [female | male | mix] (default "female")

GUI

Simple executable
go build ./cmd/horse-hunter-gui
Package for distribution
  1. Windows
go build -trimpath -ldflags "-s -w -H=windowsgui" -o HorseHunter.exe ./cmd/horse-hunter-gui
  1. macOS
# Install fyne cli tools
go install fyne.io/fyne/v2/cmd/fyne@latest

# Build binary
go build -trimpath -ldflags "-s -w" ./cmd/horse-hunter-gui

# Bundle package
fyne package -icon ./cmd/horse-hunter-gui/icon.png -name HorseHunter -release -exe horse-hunter-gui

Documentation

Index

Constants

View Source
const (
	LevelMax     Level = 0
	LevelMin     Level = 1
	LevelMix     Level = 2
	LevelDefault Level = LevelMax

	TargetFemale  Target = 0
	TargetMale    Target = 1
	TargetMix     Target = 2
	TargetDefault Target = TargetFemale

	IntervalDefault time.Duration = time.Millisecond * 200
)
View Source
const (
	WorkerIntervalMin = time.Millisecond * 10
)

Variables

View Source
var (
	LevelLookup = map[string]Level{
		"max": LevelMax,
		"min": LevelMin,
		"mix": LevelMix,
	}

	TargetLookup = map[string]Target{
		"female": TargetFemale,
		"male":   TargetMale,
		"mix":    TargetMix,
	}

	LevelName  = []string{"max", "min", "mix"}
	TargetName = []string{"female", "male", "mix"}
)
View Source
var (
	ErrWorkerIntervalInvalid = errors.New("worker interval to small (<10ms)")
	ErrWorkerAlreadyStarted  = errors.New("worker already started")
	ErrWorkerAlreadyStopped  = errors.New("worker already stopped")
)

Functions

func Cleanup

func Cleanup()

Cleanup the clipboard

func GetLine

func GetLine(level Level, target Target) string

GetLine by level and target arguments

func ValidateWorkerInterval

func ValidateWorkerInterval(interval time.Duration) error

Types

type Level

type Level int

Level of insult

type Target

type Target int

Target of insult

type Worker

type Worker struct {
	// Level of insults
	Level Level
	// Target of insults
	Target Target
	// Interval for clipboard update
	Interval time.Duration
	// contains filtered or unexported fields
}

Worker continuously write to clipboard

func NewWorker

func NewWorker(level Level, target Target, interval time.Duration) *Worker

NewWorker return a new worker

func NewWorkerDefault

func NewWorkerDefault() *Worker

NewWorker return a new worker with default config

func (*Worker) GetLine

func (w *Worker) GetLine() string

GetLine return an insult

func (*Worker) IsRunning

func (w *Worker) IsRunning() bool

func (*Worker) Start

func (w *Worker) Start() error

Start the worker

func (*Worker) Stop

func (w *Worker) Stop() error

Stop the worker

func (*Worker) StopWaitSignal

func (w *Worker) StopWaitSignal()

StopWaitSignal block until receive SIGINT or SIGTERM, then stop the worker

func (*Worker) WriteOnce

func (w *Worker) WriteOnce()

WriteOnce to clipboard

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL