Spit and polish
This commit is contained in:
parent
b5501a4178
commit
a50b22aa90
159
Command Line Interface.txt
Normal file
159
Command Line Interface.txt
Normal file
|
@ -0,0 +1,159 @@
|
|||
NAME:
|
||||
errorgen - make fun and custom error messages.
|
||||
|
||||
USAGE:
|
||||
errorgen [global options] command [command options] [arguments...]
|
||||
|
||||
AUTHOR:
|
||||
Noah Petherbridge, https://www.kirsle.net
|
||||
|
||||
COMMANDS:
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
GLOBAL OPTIONS:
|
||||
--version, -v Show program version and build information and exit. (default: false)
|
||||
--error, -e Make the dialog box be of type 'error' by default.
|
||||
|
||||
An info box has these default attributes unless overridden by
|
||||
other options:
|
||||
|
||||
Title: Error
|
||||
Text: An error has occurred.
|
||||
Icon: error
|
||||
Buttons: Ok (default: false)
|
||||
--alert, -a Make the dialog box be of type 'alert' by default.
|
||||
|
||||
An alert box has these default attributes unless overridden by
|
||||
other options:
|
||||
|
||||
Title: Warning
|
||||
Text: Are you sure you want to proceed?
|
||||
Icon: attention
|
||||
Buttons: Ok (default: false)
|
||||
--info, -i Make the dialog box be of type 'info' by default.
|
||||
|
||||
An info box has these default attributes unless overridden by
|
||||
other options:
|
||||
|
||||
Title: Information
|
||||
Text: All updates are complete.
|
||||
Icon: info
|
||||
Buttons: Ok (default: false)
|
||||
--question, -q Make the dialog box be of type 'question' by default.
|
||||
|
||||
A question box has these default attributes unless overridden by
|
||||
other options:
|
||||
|
||||
Title: Question
|
||||
Text: Are you sure you want to proceed?
|
||||
Icon: question
|
||||
Buttons: Ok, Cancel (default: false)
|
||||
--title value, -n value Set the title for the dialog box.
|
||||
|
||||
If no title is set, a default is used based on the type of dialog
|
||||
box requested (which is --info by default; see also --error,
|
||||
--info, --question)
|
||||
--text value, -t value The text displayed inside the dialog box.
|
||||
|
||||
Use \n where you want line breaks.
|
||||
|
||||
Important: the text does NOT have automatic word wrapping applied.
|
||||
Insert your own line breaks or else the dialog can be VERY wide for
|
||||
longer messages!
|
||||
--button value, -b value Add a button to the dialog.
|
||||
|
||||
Use this option as many times as you want to add multiple buttons.
|
||||
The one the user chooses will be printed to standard output. If no
|
||||
buttons, default is an Ok button. (accepts multiple inputs)
|
||||
--default value, -m value Set the default button by its label.
|
||||
|
||||
The matching --button will be made the default/primary button.
|
||||
--cancel value, -c value Set the 'cancel button'.
|
||||
|
||||
This value should match one of your --buttons and will be the
|
||||
value 'selected' if the user closes the window or hits the
|
||||
Escape key.
|
||||
--disabled value, -d value, -g value Mark buttons (by index) disabled
|
||||
|
||||
Specify a --button number (from 0 to n) that should be disabled,
|
||||
or greyed out. The user can not click on this button. (accepts multiple inputs)
|
||||
--icon value, -o value Set the icon to be displayed in the dialog box.
|
||||
|
||||
Use either a built-in icon by name (e.g. "aim_guy") or name your
|
||||
own custom PNG image from disk.
|
||||
|
||||
Built-in icon names include the following:
|
||||
|
||||
aim_guy
|
||||
aol_icon
|
||||
attention
|
||||
bomb
|
||||
bomb_dynamite
|
||||
bomb_grenade
|
||||
bubble_i
|
||||
bubble_q
|
||||
bulb
|
||||
butterfly
|
||||
cake
|
||||
circularsaw
|
||||
control_panel
|
||||
cow
|
||||
defrag
|
||||
disk_blu
|
||||
disk_blu_lbl
|
||||
disk_org
|
||||
disk_red
|
||||
disk_red_lbl
|
||||
disk_skull
|
||||
disk_yel
|
||||
dos
|
||||
e_orbit
|
||||
error
|
||||
error2
|
||||
error3
|
||||
error4
|
||||
file_cabinet
|
||||
find
|
||||
fortunecookie
|
||||
garbage_empty
|
||||
garbage_full
|
||||
gun
|
||||
hammer
|
||||
heart
|
||||
help
|
||||
hub
|
||||
hwinfo
|
||||
ic_a
|
||||
keys
|
||||
keys2
|
||||
keys3
|
||||
labtec
|
||||
mac
|
||||
mail
|
||||
mail_deleted
|
||||
mailbox
|
||||
mouth
|
||||
mycomputer
|
||||
mycomputer2
|
||||
mycomputer3
|
||||
newspaper
|
||||
peripheral
|
||||
plant_leaf
|
||||
radiation
|
||||
ram
|
||||
recycle
|
||||
recycle2
|
||||
scanner
|
||||
screw
|
||||
screw2
|
||||
setup
|
||||
sknife
|
||||
skull
|
||||
skull2
|
||||
skull3
|
||||
tux
|
||||
tux_config
|
||||
ups
|
||||
zipdisk
|
||||
zipdisks
|
||||
--help, -h show help (default: false)
|
28
README.md
28
README.md
|
@ -1,26 +1,27 @@
|
|||
# Error Message Generator 2.0
|
||||
|
||||
This is a modern remake of my "Error Message Generator" that was originally written in Perl around 2008. This one is written in Go in 2023 using the Fyne UI and aims to match and surpass the features of the older Perl version.
|
||||
This is a modern remake of my "Error Message Generator" that was originally written using Perl/Tk around 2006. This one is written in Go in 2023 using the [Fyne UI](https://fyne.io/) and aims to match and surpass the features of the original Perl version.
|
||||
|
||||
![Screenshot](screenshot.png)
|
||||
|
||||
The _original_ inspiration for this back in 2008 was an online web tool called "Atom Smasher's Error Message Generator" which generated images of error messages. My Perl ErrorGen program included all of the Atom Smasher icons. Atom Smasher's page seems offline recently, so interest has skyrocketed for my Perl ErrorGen program, so I decided to dust it off, redo it in Go and make it better than ever before.
|
||||
The _original_ inspiration for this back in 2006 was an online web tool called "Atom Smasher's Error Message Generator" which generated images of error messages. My Perl ErrorGen program included all of the Atom Smasher icons. Atom Smasher's page seems offline recently, so interest has skyrocketed for my Perl ErrorGen program, so I decided to dust it off, redo it in Go and make it better than ever before.
|
||||
|
||||
# Features
|
||||
|
||||
This program has two operating modes:
|
||||
|
||||
* By default, it will show the Main Window where you can construct and test a custom error message pop-up.
|
||||
* If given command line options, it will _just_ pop up the message box you specified on the command line and print the user's selection to its standard output.
|
||||
* MainWindow mode: by default, it will show the Main Window where you can construct and test a custom error message pop-up.
|
||||
* [Command Line Interface](#command-line-interface) (CLI): If given command-line options, it will _just_ pop up the message box you specified and print the user's selection to its standard output, useful for batch files or shell scripts to ask the user a question.
|
||||
|
||||
The current features include:
|
||||
|
||||
* Choose from 72 built-in icons that all came from the original Atom Smasher's Error Message Generator.
|
||||
* Custom title bar text and message text.
|
||||
* Configure up to three buttons (in the GUI tool; unlimited by command line) with custom labels.
|
||||
* Custom title bar and message text.
|
||||
* Configure up to three buttons (via the MainWindow; unlimited number of buttons by command line) each with custom labels.
|
||||
* Mark some buttons disabled and not clickable.
|
||||
* Command line interface to use these error dialogs from scripts and external programs:
|
||||
* The program returns the selected button text on its standard output.
|
||||
* The `--cancel` value can be printed to standard out if the user X's out of the window without selecting a button.
|
||||
* Specify which button should be the primary/default response of the Return key.
|
||||
* Specify which button should be the cancel/escape key response.
|
||||
|
||||
|
@ -29,9 +30,12 @@ The roadmap of future features include:
|
|||
* Improve the command-line interface to bring it up to par with other dialog tools such as Zenity.
|
||||
* e.g., add File Open/Save Dialogs, Color Picker Dialogs, and others that can be extremely useful to third-party programs.
|
||||
* The graphical Error Message Generator tool will probably not call these much - the primary GUI for this program is very much a fun toy. :)
|
||||
* Allow users to select their own custom icon.
|
||||
* **TO DO:** the command-line interface needs this too.
|
||||
* The graphical ErrorGen tool should allow users to browse and select a custom icon from their computer to use in their toy error boxes.
|
||||
* In the MainWindow, add a "Save" button that will turn your custom error dialog _into_ a batch file or shell script that calls the ErrorGen program's command line interface.
|
||||
* Example: you use the ErrorGen UI to create a prank dialog box and "Save" it as a .bat file on disk.
|
||||
* Making sure that the .bat and ErrorGen.exe are in the same folder together, double-clicking on the .bat script will show your error dialog without the MainWindow coming up!
|
||||
* Allow users to select a custom icon image.
|
||||
* The command-line interface already supports this.
|
||||
* The MainWindow should allow users to browse and select a custom icon from their computer to use in their toy error boxes.
|
||||
* Allow users to permanently extend the icon library with a folder of their own customs, so they don't have to browse and select a custom file every single time.
|
||||
|
||||
# Command Line Interface
|
||||
|
@ -41,6 +45,7 @@ You can call this program from batch files or shell scripts to prompt the user w
|
|||
For example, from a bash script:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
answer=`./errorgen --alert --title "Disk Failure" \
|
||||
--text "Failure to read from drive Z:/" \
|
||||
--icon defrag --button Abort --button Retry --button Fail \
|
||||
|
@ -53,7 +58,7 @@ echo "You have chosen: $answer"
|
|||
The full documentation is included below. Running `errorgen --help` from
|
||||
a text terminal will have the program print its documentation to you, but
|
||||
this won't work on the Windows version since a program must decide if it's
|
||||
a graphical or a command line app.
|
||||
a graphical or a command line app and can't be both.
|
||||
|
||||
# Built-in Icons
|
||||
|
||||
|
@ -145,6 +150,9 @@ NAME:
|
|||
USAGE:
|
||||
errorgen [global options] command [command options] [arguments...]
|
||||
|
||||
AUTHOR:
|
||||
Noah Petherbridge, https://www.kirsle.net
|
||||
|
||||
COMMANDS:
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ func (d Dialog) Show(app fyne.App) {
|
|||
// Icon + Message row.
|
||||
icon := canvas.NewImageFromResource(d.Icon)
|
||||
icon.FillMode = canvas.ImageFillOriginal
|
||||
icon.Resize(fyne.NewSize(32, 32))
|
||||
icon.SetMinSize(fyne.NewSize(32, 32))
|
||||
message := widget.NewLabel(d.Message)
|
||||
messageRow := container.New(layout.NewHBoxLayout(), layout.NewSpacer(), icon, message, layout.NewSpacer())
|
||||
|
||||
|
|
19
icons.go
19
icons.go
|
@ -2,6 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"embed"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -34,6 +36,7 @@ var (
|
|||
iconNames = []string{}
|
||||
)
|
||||
|
||||
// LoadIcons parses the built-in icons into memory.
|
||||
func LoadIcons() {
|
||||
filenames, err := fs.ReadDir("icons")
|
||||
if err != nil {
|
||||
|
@ -59,3 +62,19 @@ func LoadIcons() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LoadCustomIcon adds a custom icon (PNG image) from disk.
|
||||
func LoadCustomIcon(filename string) (basename string, err error) {
|
||||
basename = path.Base(filename)
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
i := Icon{
|
||||
name: basename,
|
||||
data: data,
|
||||
}
|
||||
icons[basename] = i
|
||||
return
|
||||
}
|
||||
|
|
4
main.go
4
main.go
|
@ -218,7 +218,9 @@ func main() {
|
|||
if icon, ok := icons[v]; ok {
|
||||
d.Icon = icon
|
||||
} else {
|
||||
fmt.Println("TO DO")
|
||||
if name, err := LoadCustomIcon(v); err == nil {
|
||||
d.Icon = icons[name]
|
||||
}
|
||||
}
|
||||
}
|
||||
if buttons := c.StringSlice("button"); len(buttons) > 0 {
|
||||
|
|
|
@ -32,7 +32,7 @@ func RunGUI() {
|
|||
// Preview of the selected icon.
|
||||
currentIcon := canvas.NewImageFromResource(d.Icon)
|
||||
currentIcon.FillMode = canvas.ImageFillOriginal
|
||||
currentIcon.Resize(fyne.NewSize(32, 32))
|
||||
currentIcon.SetMinSize(fyne.NewSize(32, 32))
|
||||
|
||||
// The icon picker row.
|
||||
labelIcon := canvas.NewText("Icon:", color.Black)
|
||||
|
|
Loading…
Reference in New Issue
Block a user