Compare commits
No commits in common. "e83f1e1719943ec8a8ab9cb4e71715c249f013e1" and "46c5f444badbeccdd93b8ac71fcf92d9f87f56e2" have entirely different histories.
e83f1e1719
...
46c5f444ba
5 changed files with 3 additions and 188 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
/phonetic-letters
|
|
|
@ -1,80 +0,0 @@
|
||||||
= phonetic-letters
|
|
||||||
|
|
||||||
This is a simple application which reveals the code word(s) from the NATO phonetic alphabet for a given set of letters from the English alphabet.
|
|
||||||
|
|
||||||
This app can be used to help you memorize the NATO phonetic alphabet.
|
|
||||||
|
|
||||||
== Installation
|
|
||||||
|
|
||||||
=== Requirements
|
|
||||||
|
|
||||||
==== Go
|
|
||||||
|
|
||||||
A minimum version of Go 1.21.0 is required for installing spruce.
|
|
||||||
Please go https://go.dev/dl/[here] to download the latest version.
|
|
||||||
|
|
||||||
=== Install with Go
|
|
||||||
|
|
||||||
[source,console]
|
|
||||||
----
|
|
||||||
git clone https://codeflow.dananglin.me.uk/apollo/phonetic-letters.git
|
|
||||||
cd phonetic-letters
|
|
||||||
go install .
|
|
||||||
----
|
|
||||||
|
|
||||||
== Usage
|
|
||||||
|
|
||||||
Reveal the code word for `g`:
|
|
||||||
[source,console]
|
|
||||||
----
|
|
||||||
$ phonetic-letters g
|
|
||||||
G - Golf
|
|
||||||
----
|
|
||||||
|
|
||||||
Reveal the code words for all the letters in `Hello, World!`:
|
|
||||||
[source,console]
|
|
||||||
----
|
|
||||||
$ phonetic-letters Hello, World!
|
|
||||||
H - Hotel
|
|
||||||
E - Echo
|
|
||||||
L - Lima
|
|
||||||
L - Lima
|
|
||||||
O - Oscar
|
|
||||||
W - Whiskey
|
|
||||||
O - Oscar
|
|
||||||
R - Romeo
|
|
||||||
L - Lima
|
|
||||||
D - Delta
|
|
||||||
----
|
|
||||||
|
|
||||||
Reveal the code words for all letters of the alphabet:
|
|
||||||
[source,console]
|
|
||||||
----
|
|
||||||
$ ./phonetic-letters --all
|
|
||||||
A - Alpha
|
|
||||||
B - Bravo
|
|
||||||
C - Charlie
|
|
||||||
D - Delta
|
|
||||||
E - Echo
|
|
||||||
F - Foxtrot
|
|
||||||
G - Golf
|
|
||||||
H - Hotel
|
|
||||||
I - India
|
|
||||||
J - Juliet
|
|
||||||
K - Kilo
|
|
||||||
L - Lima
|
|
||||||
M - Mike
|
|
||||||
N - November
|
|
||||||
O - Oscar
|
|
||||||
P - Papa
|
|
||||||
Q - Quebec
|
|
||||||
R - Romeo
|
|
||||||
S - Sierra
|
|
||||||
T - Tango
|
|
||||||
U - Uniform
|
|
||||||
V - Victor
|
|
||||||
W - Whiskey
|
|
||||||
X - Xray
|
|
||||||
Y - Yankee
|
|
||||||
Z - Zulu
|
|
||||||
----
|
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# phonetic-letters
|
||||||
|
|
||||||
|
Reveals the code words from the NATO phonetic alphabet for a given set of letters from the alphabet.
|
3
go.mod
3
go.mod
|
@ -1,3 +0,0 @@
|
||||||
module codeflow.dananglin.me.uk/apollo/phonetic-letters
|
|
||||||
|
|
||||||
go 1.21
|
|
|
@ -1,104 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
var all bool
|
|
||||||
|
|
||||||
flag.BoolVar(&all, "all", false, "reveal the code words of all the letters in the English alphabet.")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if all {
|
|
||||||
fmt.Println(phoneticLetters(fullAlphabet()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
args := flag.Args()
|
|
||||||
|
|
||||||
if len(args) < 1 {
|
|
||||||
fmt.Println("ERROR: expected an argument")
|
|
||||||
os.Exit(1)
|
|
||||||
} else if len(args) == 1 {
|
|
||||||
fmt.Println(phoneticLetters(args[0]))
|
|
||||||
} else {
|
|
||||||
input := ""
|
|
||||||
for i := range args {
|
|
||||||
input = input + args[i]
|
|
||||||
}
|
|
||||||
fmt.Println(phoneticLetters(input))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func phoneticLetters(letters string) string {
|
|
||||||
letters = strings.ToLower(letters)
|
|
||||||
|
|
||||||
b := strings.Builder{}
|
|
||||||
|
|
||||||
for _, r := range letters {
|
|
||||||
switch r {
|
|
||||||
case 'a':
|
|
||||||
b.WriteString("A - Alpha\n")
|
|
||||||
case 'b':
|
|
||||||
b.WriteString("B - Bravo\n")
|
|
||||||
case 'c':
|
|
||||||
b.WriteString("C - Charlie\n")
|
|
||||||
case 'd':
|
|
||||||
b.WriteString("D - Delta\n")
|
|
||||||
case 'e':
|
|
||||||
b.WriteString("E - Echo\n")
|
|
||||||
case 'f':
|
|
||||||
b.WriteString("F - Foxtrot\n")
|
|
||||||
case 'g':
|
|
||||||
b.WriteString("G - Golf\n")
|
|
||||||
case 'h':
|
|
||||||
b.WriteString("H - Hotel\n")
|
|
||||||
case 'i':
|
|
||||||
b.WriteString("I - India\n")
|
|
||||||
case 'j':
|
|
||||||
b.WriteString("J - Juliet\n")
|
|
||||||
case 'k':
|
|
||||||
b.WriteString("K - Kilo\n")
|
|
||||||
case 'l':
|
|
||||||
b.WriteString("L - Lima\n")
|
|
||||||
case 'm':
|
|
||||||
b.WriteString("M - Mike\n")
|
|
||||||
case 'n':
|
|
||||||
b.WriteString("N - November\n")
|
|
||||||
case 'o':
|
|
||||||
b.WriteString("O - Oscar\n")
|
|
||||||
case 'p':
|
|
||||||
b.WriteString("P - Papa\n")
|
|
||||||
case 'q':
|
|
||||||
b.WriteString("Q - Quebec\n")
|
|
||||||
case 'r':
|
|
||||||
b.WriteString("R - Romeo\n")
|
|
||||||
case 's':
|
|
||||||
b.WriteString("S - Sierra\n")
|
|
||||||
case 't':
|
|
||||||
b.WriteString("T - Tango\n")
|
|
||||||
case 'u':
|
|
||||||
b.WriteString("U - Uniform\n")
|
|
||||||
case 'v':
|
|
||||||
b.WriteString("V - Victor\n")
|
|
||||||
case 'w':
|
|
||||||
b.WriteString("W - Whiskey\n")
|
|
||||||
case 'x':
|
|
||||||
b.WriteString("X - Xray\n")
|
|
||||||
case 'y':
|
|
||||||
b.WriteString("Y - Yankee\n")
|
|
||||||
case 'z':
|
|
||||||
b.WriteString("Z - Zulu\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func fullAlphabet() string {
|
|
||||||
return "a b c d e f g h i j k l m n o p q r s t u v w x y z"
|
|
||||||
}
|
|
Loading…
Reference in a new issue