Skip to content

Commit e9e084b

Browse files
committed
style, feat: some formatting, handle ACTUAL 404 not found error LMAO and add uninstall to makefile
1 parent aef3d07 commit e9e084b

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ build:
22
go build
33

44
install:
5-
sudo cp ./http-cat-cli /usr/bin/http-cat
5+
sudo cp ./http-cat-cli /usr/bin/http-cat
6+
7+
uninstall:
8+
sudo rm /usr/bin/http-cat

httpcat.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func main() {
2525
if !isStringNumber(http_status_code) {
2626
fmt.Println(
2727
"You must provide a HTTP status code! " +
28-
"E.g. http-cat 404, http-cat 500. Run 'http-cat --help' for more help.",
28+
"(E.g. http-cat 404, http-cat 500) \nRun 'http-cat --help' for more information.",
2929
)
3030
return nil
3131
}
@@ -38,6 +38,16 @@ func main() {
3838
log.Fatalln("GET request to HTTP Cat API failed:", err)
3939
}
4040

41+
if response.StatusCode >= 400 {
42+
if response.StatusCode == 404 {
43+
log.Fatalln(
44+
"A 🐈 kitty corresponding to that HTTP status isn't available! Error:", response.Status,
45+
)
46+
}
47+
48+
log.Fatalln("API Error:", response.Status)
49+
}
50+
4151
var temp_directory_path string = getTempDir()
4252

4353
if _, err := os.Stat(temp_directory_path); os.IsNotExist(err) {
@@ -57,7 +67,9 @@ func main() {
5767
log.Fatalln("Failed to write the 🐈 kitty in the temp directory:", err)
5868
}
5969

60-
output, err := exec.Command("chafa", path_to_image, "--scale", "0.7").Output()
70+
output, err := exec.Command(
71+
"chafa", path_to_image, "--scale", "0.7",
72+
).Output()
6173

6274
if err != nil {
6375
log.Fatalln(

0 commit comments

Comments
 (0)