-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (42 loc) · 833 Bytes
/
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
package main
import (
"fmt"
"os"
)
func interactive_mode() {
fmt.Println("Welcome to snnt_notes! Still under development!")
}
func program_was_invoked_without_args() bool {
return len(os.Args) == 1
}
func first_arg_is_meta_arg() bool {
if program_was_invoked_without_args() {
panic(1)
}
return os.Args[1] == "--arg"
}
func handle_args() {
if !first_arg_is_meta_arg() {
panic(2)
}
fmt.Println("Arg handling: snnt_notes was invoked with these args:")
for index, arg := range os.Args {
fmt.Printf("Index %v: %v\n", index, arg)
}
}
func direct_mode() {
for _, arg := range os.Args {
fmt.Println(arg)
}
var input string
fmt.Scanln(&input)
}
func main() {
if program_was_invoked_without_args() {
interactive_mode()
} else if first_arg_is_meta_arg() {
handle_args()
} else {
direct_mode()
}
}