Compare commits

...
10 Commits
Author SHA1 Message Date
mroberts 2fc52f70ab License format 2024-02-15 21:57:08 +00:00
mroberts bdf6b33a05 Readme tweak 2024-02-15 21:52:26 +00:00
mroberts ba5aa4e5e2 Added a license & readme 2024-02-15 21:51:09 +00:00
mroberts 77d25f2a11 Chagned to verb-noun instead of noun-verb 2024-02-15 21:36:33 +00:00
mroberts b7b4f799e7 Added flag to copy to clipboard 2024-02-15 19:44:25 +00:00
mroberts 1af2cfafa4 Changed to public url 2024-02-15 19:26:06 +00:00
mroberts e93aa0ce5b Trying internal URL 2024-02-15 19:24:47 +00:00
mroberts 8fcda22083 Set create_release to only happen on tags 2024-02-15 19:22:42 +00:00
mroberts f740d758ba Fixed multiple command usage 2024-02-15 19:18:11 +00:00
mroberts b4f5ec23eb Added creating releases 2024-02-15 19:16:34 +00:00
7 changed files with 101 additions and 8 deletions
+17 -1
View File
@@ -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
+1 -1
View File
@@ -19,4 +19,4 @@
# Go workspace file
go.work
usergen
dist/*
+20
View 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.
+40
View File
@@ -1 +1,41 @@
[![Build Status](https://drone.mroberts.dev/api/badges/mickey/usergen/status.svg)](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
View File
@@ -1,3 +1,5 @@
module github.com/mickeyr/usergen
go 1.22.0
require github.com/atotto/clipboard v0.1.4 // indirect
+2
View 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=
+18 -5
View File
@@ -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(&copy, "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())
}