errorgen/README.html

560 lines
20 KiB
HTML
Raw Normal View History

2023-01-22 20:02:21 +00:00
<h1 id="error-message-generator-2.0">Error Message Generator 2.0</h1>
<p>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 <a href="https://fyne.io/">Fyne UI</a> and aims to match and surpass the features of the original Perl version.</p>
<figure>
<img src="screenshot.png" alt="Screenshot" /><figcaption aria-hidden="true">Screenshot</figcaption>
</figure>
<p>The <em>original</em> inspiration for this back in 2006 was an online web tool called “Atom Smashers Error Message Generator” which generated images of error messages. My Perl ErrorGen program included all of the Atom Smasher icons. Atom Smashers 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.</p>
<h1 id="features">Features</h1>
<p>This program has two operating modes:</p>
<ul>
<li>MainWindow mode: by default, it will show the Main Window where you can construct and test a custom error message pop-up.</li>
<li><a href="#command-line-interface">Command Line Interface</a> (CLI): If given command-line options, it will <em>just</em> pop up the message box you specified and print the users selection to its standard output, useful for batch files or shell scripts to ask the user a question.</li>
</ul>
<p>The current features include:</p>
<ul>
<li>Choose from 72 built-in icons that all came from the original Atom Smashers Error Message Generator.</li>
<li>Custom title bar and message text.</li>
<li>Configure up to three buttons (via the MainWindow; unlimited number of buttons by command line) each with custom labels.</li>
<li>Mark some buttons disabled and not clickable.</li>
<li>Command line interface to use these error dialogs from scripts and external programs:
<ul>
<li>The program returns the selected button text on its standard output.</li>
<li>The <code>--cancel</code> value can be printed to standard out if the user Xs out of the window without selecting a button.</li>
<li>Specify which button should be the primary/default response of the Return key.</li>
<li>Specify which button should be the cancel/escape key response.</li>
</ul></li>
</ul>
<p>The roadmap of future features include:</p>
<ul>
<li>Improve the command-line interface to bring it up to par with other dialog tools such as Zenity.
<ul>
<li>e.g., add File Open/Save Dialogs, Color Picker Dialogs, and others that can be extremely useful to third-party programs.</li>
<li>The graphical Error Message Generator tool will probably not call these much - the primary GUI for this program is very much a fun toy. :)</li>
</ul></li>
<li>In the MainWindow, add a “Save” button that will turn your custom error dialog <em>into</em> a batch file or shell script that calls the ErrorGen programs command line interface.
<ul>
<li>Example: you use the ErrorGen UI to create a prank dialog box and “Save” it as a .bat file on disk.</li>
<li>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!</li>
</ul></li>
<li>Allow users to select a custom icon image.
<ul>
<li>The command-line interface already supports this.</li>
<li>The MainWindow should allow users to browse and select a custom icon from their computer to use in their toy error boxes.</li>
<li>Allow users to permanently extend the icon library with a folder of their own customs, so they dont have to browse and select a custom file every single time.</li>
</ul></li>
</ul>
<h1 id="command-line-interface">Command Line Interface</h1>
<p>You can call this program from batch files or shell scripts to prompt the user with a graphical dialog box and read the button they chose from this programs standard output.</p>
<p>For example, from a bash script:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co">#!/bin/bash</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="va">answer</span><span class="op">=</span><span class="kw">`</span><span class="ex">./errorgen</span> <span class="at">--alert</span> <span class="at">--title</span> <span class="st">&quot;Disk Failure&quot;</span> <span class="dt">\</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="at">--text</span> <span class="st">&quot;Failure to read from drive Z:/&quot;</span> <span class="dt">\</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="at">--icon</span> defrag <span class="at">--button</span> Abort <span class="at">--button</span> Retry <span class="at">--button</span> Fail <span class="dt">\</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> <span class="at">--default</span> 1 <span class="at">--cancel</span> Fail<span class="kw">`</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;You have chosen: </span><span class="va">$answer</span><span class="st">&quot;</span></span></code></pre></div>
<figure>
<img src="error.png" alt="Screenshot from the above command" /><figcaption aria-hidden="true">Screenshot from the above command</figcaption>
</figure>
<p>The full documentation is included below. Running <code>errorgen --help</code> from a text terminal will have the program print its documentation to you, but this wont work on the Windows version since a program must decide if its a graphical or a command line app and cant be both.</p>
<h1 id="built-in-icons">Built-in Icons</h1>
<p>These are all the icons that currently come with ErrorGen:</p>
<table>
<thead>
<tr class="header">
<th>Image</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="icons/aim_guy.png" alt="aim_guy" /></td>
<td>aim_guy</td>
</tr>
<tr class="even">
<td><img src="icons/aol_icon.png" alt="aol_icon" /></td>
<td>aol_icon</td>
</tr>
<tr class="odd">
<td><img src="icons/attention.png" alt="attention" /></td>
<td>attention</td>
</tr>
<tr class="even">
<td><img src="icons/bomb.png" alt="bomb" /></td>
<td>bomb</td>
</tr>
<tr class="odd">
<td><img src="icons/bomb_dynamite.png" alt="bomb_dynamite" /></td>
<td>bomb_dynamite</td>
</tr>
<tr class="even">
<td><img src="icons/bomb_grenade.png" alt="bomb_grenade" /></td>
<td>bomb_grenade</td>
</tr>
<tr class="odd">
<td><img src="icons/bubble_i.png" alt="bubble_i" /></td>
<td>bubble_i</td>
</tr>
<tr class="even">
<td><img src="icons/bubble_q.png" alt="bubble_q" /></td>
<td>bubble_q</td>
</tr>
<tr class="odd">
<td><img src="icons/bulb.png" alt="bulb" /></td>
<td>bulb</td>
</tr>
<tr class="even">
<td><img src="icons/butterfly.png" alt="butterfly" /></td>
<td>butterfly</td>
</tr>
<tr class="odd">
<td><img src="icons/cake.png" alt="cake" /></td>
<td>cake</td>
</tr>
<tr class="even">
<td><img src="icons/circularsaw.png" alt="circularsaw" /></td>
<td>circularsaw</td>
</tr>
<tr class="odd">
<td><img src="icons/control_panel.png" alt="control_panel" /></td>
<td>control_panel</td>
</tr>
<tr class="even">
<td><img src="icons/cow.png" alt="cow" /></td>
<td>cow</td>
</tr>
<tr class="odd">
<td><img src="icons/defrag.png" alt="defrag" /></td>
<td>defrag</td>
</tr>
<tr class="even">
<td><img src="icons/disk_blu.png" alt="disk_blu" /></td>
<td>disk_blu</td>
</tr>
<tr class="odd">
<td><img src="icons/disk_blu_lbl.png" alt="disk_blu_lbl" /></td>
<td>disk_blu_lbl</td>
</tr>
<tr class="even">
<td><img src="icons/disk_org.png" alt="disk_org" /></td>
<td>disk_org</td>
</tr>
<tr class="odd">
<td><img src="icons/disk_red.png" alt="disk_red" /></td>
<td>disk_red</td>
</tr>
<tr class="even">
<td><img src="icons/disk_red_lbl.png" alt="disk_red_lbl" /></td>
<td>disk_red_lbl</td>
</tr>
<tr class="odd">
<td><img src="icons/disk_skull.png" alt="disk_skull" /></td>
<td>disk_skull</td>
</tr>
<tr class="even">
<td><img src="icons/disk_yel.png" alt="disk_yel" /></td>
<td>disk_yel</td>
</tr>
<tr class="odd">
<td><img src="icons/dos.png" alt="dos" /></td>
<td>dos</td>
</tr>
<tr class="even">
<td><img src="icons/e_orbit.png" alt="e_orbit" /></td>
<td>e_orbit</td>
</tr>
<tr class="odd">
<td><img src="icons/error.png" alt="error" /></td>
<td>error</td>
</tr>
<tr class="even">
<td><img src="icons/error2.png" alt="error2" /></td>
<td>error2</td>
</tr>
<tr class="odd">
<td><img src="icons/error3.png" alt="error3" /></td>
<td>error3</td>
</tr>
<tr class="even">
<td><img src="icons/error4.png" alt="error4" /></td>
<td>error4</td>
</tr>
<tr class="odd">
<td><img src="icons/file_cabinet.png" alt="file_cabinet" /></td>
<td>file_cabinet</td>
</tr>
<tr class="even">
<td><img src="icons/find.png" alt="find" /></td>
<td>find</td>
</tr>
<tr class="odd">
<td><img src="icons/fortunecookie.png" alt="fortunecookie" /></td>
<td>fortunecookie</td>
</tr>
<tr class="even">
<td><img src="icons/garbage_empty.png" alt="garbage_empty" /></td>
<td>garbage_empty</td>
</tr>
<tr class="odd">
<td><img src="icons/garbage_full.png" alt="garbage_full" /></td>
<td>garbage_full</td>
</tr>
<tr class="even">
<td><img src="icons/gun.png" alt="gun" /></td>
<td>gun</td>
</tr>
<tr class="odd">
<td><img src="icons/hammer.png" alt="hammer" /></td>
<td>hammer</td>
</tr>
<tr class="even">
<td><img src="icons/heart.png" alt="heart" /></td>
<td>heart</td>
</tr>
<tr class="odd">
<td><img src="icons/help.png" alt="help" /></td>
<td>help</td>
</tr>
<tr class="even">
<td><img src="icons/hub.png" alt="hub" /></td>
<td>hub</td>
</tr>
<tr class="odd">
<td><img src="icons/hwinfo.png" alt="hwinfo" /></td>
<td>hwinfo</td>
</tr>
<tr class="even">
<td><img src="icons/ic_a.png" alt="ic_a" /></td>
<td>ic_a</td>
</tr>
<tr class="odd">
<td><img src="icons/keys.png" alt="keys" /></td>
<td>keys</td>
</tr>
<tr class="even">
<td><img src="icons/keys2.png" alt="keys2" /></td>
<td>keys2</td>
</tr>
<tr class="odd">
<td><img src="icons/keys3.png" alt="keys3" /></td>
<td>keys3</td>
</tr>
<tr class="even">
<td><img src="icons/labtec.png" alt="labtec" /></td>
<td>labtec</td>
</tr>
<tr class="odd">
<td><img src="icons/mac.png" alt="mac" /></td>
<td>mac</td>
</tr>
<tr class="even">
<td><img src="icons/mail.png" alt="mail" /></td>
<td>mail</td>
</tr>
<tr class="odd">
<td><img src="icons/mail_deleted.png" alt="mail_deleted" /></td>
<td>mail_deleted</td>
</tr>
<tr class="even">
<td><img src="icons/mailbox.png" alt="mailbox" /></td>
<td>mailbox</td>
</tr>
<tr class="odd">
<td><img src="icons/mouth.png" alt="mouth" /></td>
<td>mouth</td>
</tr>
<tr class="even">
<td><img src="icons/mycomputer.png" alt="mycomputer" /></td>
<td>mycomputer</td>
</tr>
<tr class="odd">
<td><img src="icons/mycomputer2.png" alt="mycomputer2" /></td>
<td>mycomputer2</td>
</tr>
<tr class="even">
<td><img src="icons/mycomputer3.png" alt="mycomputer3" /></td>
<td>mycomputer3</td>
</tr>
<tr class="odd">
<td><img src="icons/newspaper.png" alt="newspaper" /></td>
<td>newspaper</td>
</tr>
<tr class="even">
<td><img src="icons/peripheral.png" alt="peripheral" /></td>
<td>peripheral</td>
</tr>
<tr class="odd">
<td><img src="icons/plant_leaf.png" alt="plant_leaf" /></td>
<td>plant_leaf</td>
</tr>
<tr class="even">
<td><img src="icons/radiation.png" alt="radiation" /></td>
<td>radiation</td>
</tr>
<tr class="odd">
<td><img src="icons/ram.png" alt="ram" /></td>
<td>ram</td>
</tr>
<tr class="even">
<td><img src="icons/recycle.png" alt="recycle" /></td>
<td>recycle</td>
</tr>
<tr class="odd">
<td><img src="icons/recycle2.png" alt="recycle2" /></td>
<td>recycle2</td>
</tr>
<tr class="even">
<td><img src="icons/scanner.png" alt="scanner" /></td>
<td>scanner</td>
</tr>
<tr class="odd">
<td><img src="icons/screw.png" alt="screw" /></td>
<td>screw</td>
</tr>
<tr class="even">
<td><img src="icons/screw2.png" alt="screw2" /></td>
<td>screw2</td>
</tr>
<tr class="odd">
<td><img src="icons/setup.png" alt="setup" /></td>
<td>setup</td>
</tr>
<tr class="even">
<td><img src="icons/sknife.png" alt="sknife" /></td>
<td>sknife</td>
</tr>
<tr class="odd">
<td><img src="icons/skull.png" alt="skull" /></td>
<td>skull</td>
</tr>
<tr class="even">
<td><img src="icons/skull2.png" alt="skull2" /></td>
<td>skull2</td>
</tr>
<tr class="odd">
<td><img src="icons/skull3.png" alt="skull3" /></td>
<td>skull3</td>
</tr>
<tr class="even">
<td><img src="icons/tux.png" alt="tux" /></td>
<td>tux</td>
</tr>
<tr class="odd">
<td><img src="icons/tux_config.png" alt="tux_config" /></td>
<td>tux_config</td>
</tr>
<tr class="even">
<td><img src="icons/ups.png" alt="ups" /></td>
<td>ups</td>
</tr>
<tr class="odd">
<td><img src="icons/zipdisk.png" alt="zipdisk" /></td>
<td>zipdisk</td>
</tr>
<tr class="even">
<td><img src="icons/zipdisks.png" alt="zipdisks" /></td>
<td>zipdisks</td>
</tr>
</tbody>
</table>
<h1 id="command-line-usage">Command Line Usage</h1>
<p>The result of <code>errorgen --help</code>:</p>
<pre><code>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 &#39;error&#39; 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 &#39;alert&#39; 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 &#39;info&#39; 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 &#39;question&#39; 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 &#39;cancel button&#39;.
This value should match one of your --buttons and will be the
value &#39;selected&#39; 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. &quot;aim_guy&quot;) 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)</code></pre>
<h1 id="building">Building</h1>
<p>Requirements:</p>
<ul>
<li>Go: https://golang.org</li>
<li>Fyne dependencies: https://developer.fyne.io/started/</li>
</ul>
<p>Fedora: <code>sudo dnf install golang gcc libXcursor-devel libXrandr-devel mesa-libGL-devel libXi-devel libXinerama-devel libXxf86vm-devel</code></p>
<p>Ubuntu/Debian: <code>sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev</code></p>
<p>There is a GNU Makefile to make build commands easier to remember.</p>
<ul>
<li><code>make setup</code> installs Go dependencies for this project.</li>
<li><code>make</code> or <code>make build</code> will produce the ./errorgen binary.</li>
<li><code>make run</code> runs the Go app locally for development and testing.]</li>
<li><code>make clean</code> removes the built binary.</li>
</ul>
<p>Cross compiling: install Docker and fyne-cross and run <code>make release</code> to produce the build. To install fyne-cross:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">go</span> install github.com/fyne-io/fyne-cross</span></code></pre></div>
<p>In case of permission errors (Docker often needs run as root) you can try sudo running fyne-cross directly, e.g. to produce Windows amd64 and i386 builds a command like:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co"># which fyne-cross to use your locally installed Go binary for the current user,</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="co"># so that root doesn&#39;t need to also install fyne-cross and have a $PATH set up.</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> <span class="va">$(</span><span class="fu">which</span> fyne-cross<span class="va">)</span> windows <span class="at">-arch</span><span class="op">=</span><span class="dt">\*</span></span></code></pre></div>
<h1 id="license-author">License &amp; Author</h1>
<p>Icons from the Atom Smasher Error Message Generator.</p>
<p>Developed by Noah Petherbridge, <a href="https://www.kirsle.net/" class="uri">https://www.kirsle.net/</a></p>
<p>See my web page about this at <a href="https://www.kirsle.net/errorgen" class="uri">https://www.kirsle.net/errorgen</a></p>
<pre><code>Error Message Generator
Copyright (C) 2023 Noah Petherbridge
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;.</code></pre>