-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.go
70 lines (49 loc) · 1.25 KB
/
Main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
"os"
"github.com/meritos/go-study/strings"
)
func main () {
strings.CountWord("Hello World")
if len(os.Args) < 2 {
fmt.Println("\n For Usage: ")
fmt.Println(" --help -h\n")
} else {
if os.Args[1] == "--help" || os.Args[1] == "-h" {
printHelp()
}
if os.Args[1] == "--run" || os.Args[1] == "-r" {
if len(os.Args) < 3 {
fmt.Println("\n Specify one of the samples to run\n")
} else {
sample := os.Args[2]
if sample == "CountWord" {
if (len(os.Args) < 4) {
fmt.Println("\n Specify string to run by CountWord sample \n e.g: \"Hello World\" ")
} else {
fmt.Println("\n Result: ", strings.CountWord(os.Args[3]), "\n")
}
}
}
}
}
}
/**
* printHelp()
* nothing fancy command line options
*/
func printHelp(){
fmt.Println("Run Samples ")
fmt.Println("")
fmt.Println("Usage: ")
fmt.Println("")
fmt.Println(" --help -h: ....... print help message ")
fmt.Println(" --run -r: ....... run single sample ")
fmt.Println("")
fmt.Println("Samples:")
fmt.Println("")
fmt.Println(" CountWord: gets string e.g. \"Hello World\" and returns words sizes")
fmt.Println(" inside the string result: \"Hello5 World5\" ")
fmt.Println();
}