Skip to content

Commit b525f31

Browse files
committed
improve error messages and help output
1 parent 0307edd commit b525f31

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

flags.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const helpText = `
2323
lab <extension> Create and open a new file (e.g., lab js)
2424
lab <number> Open file by number
2525
lab 0 Open config file
26+
lab List all lab files
2627
lab -v, --version Show version
2728
lab -h, --help Show this help
2829
lab -d, --delete <number> Delete file by number
@@ -33,6 +34,7 @@ const helpText = `
3334
lab js Create a JavaScript file
3435
lab 1 Open most recent file
3536
lab 0 Edit config
37+
lab List all lab files
3638
lab -d 2 Delete file #2
3739
lab -p 1 Show the path of file #1
3840
lab -r 1 node Run the file #1 with Node.js
@@ -77,7 +79,7 @@ func handleFlags(labVersion string, organizedFiles []os.DirEntry, labdir string)
7779

7880
case "-d", "--delete":
7981
if fileDir == "" || file == nil {
80-
fmt.Printf("\n " + Yellow + "No file specified for deletion.\n\n" + Reset)
82+
fmt.Printf("\n " + Yellow + "No file specified for deletion. Use 'lab -d <number>'\n\n" + Reset)
8183
return
8284
}
8385
err := os.Remove(fileDir)
@@ -88,11 +90,15 @@ func handleFlags(labVersion string, organizedFiles []os.DirEntry, labdir string)
8890
fmt.Printf("\n "+Red+"%v "+Reset+"has been deleted from the lab!\n\n", file.Name())
8991

9092
case "-p", "--path":
93+
if fileDir == "" || file == nil {
94+
fmt.Printf("\n " + Yellow + "No file specified for retrieving the path. Use 'lab -p <number>'\n\n" + Reset)
95+
return
96+
}
9197
fmt.Println(fileDir)
9298

9399
case "-r", "--run":
94100
if (len(os.Args)) < 4 {
95-
fmt.Println(Red + "Missing runner command. Provide a runner as a third argument." + Reset)
101+
fmt.Println("\n " + Yellow + "Missing arguments. Use 'lab -r <number> <command>'\n\n" + Reset)
96102
return
97103
}
98104
runner := os.Args[3]

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
)
1010

11-
const labVersion = "1.2.0"
11+
const labVersion = "1.2.1"
1212

1313
func checkRequiredConfigs(cfg map[string]string, keys []string) {
1414
for _, key := range keys {

0 commit comments

Comments
 (0)