Compare commits
No commits in common. "2fc52f70abced16d08e02efd01905459186fc1fa" and "dca57a3acda9f22e06a328f8aa4aee724073d01e" have entirely different histories.
2fc52f70ab
...
dca57a3acd
18
.drone.yml
18
.drone.yml
@ -5,20 +5,4 @@ steps:
|
|||||||
- name: build
|
- name: build
|
||||||
image: golang
|
image: golang
|
||||||
commands:
|
commands:
|
||||||
- GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/usergen-amd64-windows.exe
|
- go build -ldflags="-s -w"
|
||||||
- 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 workspace file
|
||||||
go.work
|
go.work
|
||||||
dist/*
|
usergen
|
||||||
20
LICENSE
20
LICENSE
@ -1,20 +0,0 @@
|
|||||||
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,41 +1 @@
|
|||||||
[](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,5 +1,3 @@
|
|||||||
module github.com/mickeyr/usergen
|
module github.com/mickeyr/usergen
|
||||||
|
|
||||||
go 1.22.0
|
go 1.22.0
|
||||||
|
|
||||||
require github.com/atotto/clipboard v0.1.4 // indirect
|
|
||||||
|
|||||||
2
go.sum
2
go.sum
@ -1,2 +0,0 @@
|
|||||||
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,15 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"embed"
|
"embed"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/atotto/clipboard"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -21,7 +18,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var count int
|
var count int
|
||||||
var copy bool
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
nounsContents, _ := res.ReadFile("resources/nouns.txt")
|
nounsContents, _ := res.ReadFile("resources/nouns.txt")
|
||||||
@ -30,27 +26,18 @@ func init() {
|
|||||||
verbsContents, _ := res.ReadFile("resources/verbs.txt")
|
verbsContents, _ := res.ReadFile("resources/verbs.txt")
|
||||||
verbs = strings.Split(string(verbsContents), "\n")
|
verbs = strings.Split(string(verbsContents), "\n")
|
||||||
|
|
||||||
flag.IntVar(&count, "n", 5, "number of nouns and verbs to print")
|
flag.IntVar(&count, "count", 10, "number of nouns and verbs to print")
|
||||||
flag.BoolVar(©, "c", false, "copies the output to the clipboard")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
var output bytes.Buffer
|
fmt.Println("count is ", count)
|
||||||
|
|
||||||
|
// Print the first 10 nouns and verbs
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
if i > 0 {
|
|
||||||
output.WriteString("\n")
|
|
||||||
}
|
|
||||||
randomNounIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((nouns)))))
|
randomNounIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((nouns)))))
|
||||||
randomVerbIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((verbs)))))
|
randomVerbIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((verbs)))))
|
||||||
var username = fmt.Sprintf("%s-%s", verbs[randomVerbIdx.Int64()], nouns[randomNounIdx.Int64()])
|
fmt.Printf("%s-%s\n", nouns[randomNounIdx.Int64()], verbs[randomVerbIdx.Int64()])
|
||||||
output.WriteString(username)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if copy {
|
|
||||||
clipboard.WriteAll(output.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(output.String())
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user