Compare commits
10 Commits
dca57a3acd
...
2fc52f70ab
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fc52f70ab | |||
| bdf6b33a05 | |||
| ba5aa4e5e2 | |||
| 77d25f2a11 | |||
| b7b4f799e7 | |||
| 1af2cfafa4 | |||
| e93aa0ce5b | |||
| 8fcda22083 | |||
| f740d758ba | |||
| b4f5ec23eb |
18
.drone.yml
18
.drone.yml
@ -5,4 +5,20 @@ steps:
|
||||
- name: build
|
||||
image: golang
|
||||
commands:
|
||||
- go build -ldflags="-s -w"
|
||||
- GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/usergen-amd64-windows.exe
|
||||
- GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/usergen-amd64-linux
|
||||
- GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/usergen-amd64-darwin
|
||||
|
||||
- name: create_release
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_public_releases
|
||||
base_url: https://git.mroberts.dev/
|
||||
files: dist/*
|
||||
checksum:
|
||||
- sha256
|
||||
- md5
|
||||
- sha1
|
||||
when:
|
||||
event: tag
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -19,4 +19,4 @@
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
usergen
|
||||
dist/*
|
||||
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright 2024 Malcolm Roberts
|
||||
|
||||
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.
|
||||
42
README.md
42
README.md
@ -1 +1,41 @@
|
||||
[](https://drone.mroberts.dev/mickey/usergen)
|
||||
[](https://drone.mroberts.dev/mickey/usergen)
|
||||
|
||||
# Usergen - Random Username Generator
|
||||
|
||||
## Overview
|
||||
|
||||
`usergen` is a simple yet powerful utility written in Go, designed to generate random usernames by combining verbs with nouns in a `verb-noun` format. It's perfect for creating unique and memorable usernames for a variety of applications. The utility is flexible, allowing users to specify the number of usernames to generate and optionally copy the output directly to the clipboard.
|
||||
|
||||
## Features
|
||||
|
||||
- **Written in Go**: Fast and efficient execution.
|
||||
- **Customizable Output**: Control over the number of usernames generated.
|
||||
- **Clipboard Support**: Easy copying of generated usernames to the clipboard for immediate use.
|
||||
- **Cross-Platform Compatibility**: Supports OSX, Windows (tested on Windows 7 but should work on others), and Linux/Unix (requires 'xclip' or 'xsel').
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installation
|
||||
|
||||
You can download the provided release for your OS on the [releases page](https://git.mroberts.dev/mickey/usergen/releases)
|
||||
|
||||
### Usage
|
||||
|
||||
Run usergen with the following command-line arguments:
|
||||
|
||||
* `-n X` to specify the number of usernames to generate (where X is the number of usernames).
|
||||
* `-c` to copy the generated usernames to the clipboard.
|
||||
|
||||
```bash
|
||||
usergen -n 1 -c
|
||||
```
|
||||
|
||||
This will generate a random username and copy it to the clipboard
|
||||
|
||||
### Development
|
||||
|
||||
The repository includes a .devcontainer definition for easy development setup using Visual Studio Code's Dev Containers. This allows you to work with a consistent development environment.
|
||||
|
||||
## License
|
||||
|
||||
Distributed under the MIT License. See LICENSE file in the repository for more information.
|
||||
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
||||
module github.com/mickeyr/usergen
|
||||
|
||||
go 1.22.0
|
||||
|
||||
require github.com/atotto/clipboard v0.1.4 // indirect
|
||||
|
||||
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
||||
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||
23
main.go
23
main.go
@ -1,12 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"github.com/atotto/clipboard"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -18,6 +21,7 @@ var (
|
||||
)
|
||||
|
||||
var count int
|
||||
var copy bool
|
||||
|
||||
func init() {
|
||||
nounsContents, _ := res.ReadFile("resources/nouns.txt")
|
||||
@ -26,18 +30,27 @@ func init() {
|
||||
verbsContents, _ := res.ReadFile("resources/verbs.txt")
|
||||
verbs = strings.Split(string(verbsContents), "\n")
|
||||
|
||||
flag.IntVar(&count, "count", 10, "number of nouns and verbs to print")
|
||||
|
||||
flag.IntVar(&count, "n", 5, "number of nouns and verbs to print")
|
||||
flag.BoolVar(©, "c", false, "copies the output to the clipboard")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
fmt.Println("count is ", count)
|
||||
var output bytes.Buffer
|
||||
|
||||
// Print the first 10 nouns and verbs
|
||||
for i := 0; i < count; i++ {
|
||||
if i > 0 {
|
||||
output.WriteString("\n")
|
||||
}
|
||||
randomNounIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((nouns)))))
|
||||
randomVerbIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((verbs)))))
|
||||
fmt.Printf("%s-%s\n", nouns[randomNounIdx.Int64()], verbs[randomVerbIdx.Int64()])
|
||||
var username = fmt.Sprintf("%s-%s", verbs[randomVerbIdx.Int64()], nouns[randomNounIdx.Int64()])
|
||||
output.WriteString(username)
|
||||
}
|
||||
|
||||
if copy {
|
||||
clipboard.WriteAll(output.String())
|
||||
}
|
||||
|
||||
fmt.Println(output.String())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user