-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
68 lines (59 loc) · 1.37 KB
/
main.go
File metadata and controls
68 lines (59 loc) · 1.37 KB
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
package main
import (
"log"
"os"
"github.com/kruceo/marceo-go/library/packs"
)
const version string = "0.6.4"
func main() {
var inputText string = ""
var outputPath string = ""
var isParalel bool = false
for index, v := range os.Args {
if v == "-i" {
if len(os.Args) > index+1 {
argInput := os.Args[index+1]
file, err := os.ReadFile(argInput)
if err != nil {
log.Fatal(err)
}
inputText = string(file)
} else {
log.Fatal("No input")
}
}
if v == "-o" {
if len(os.Args) > index+1 {
argInput := os.Args[index+1]
outputPath = argInput
} else {
log.Fatal("No input")
}
}
if v == "-p" {
isParalel = true
}
if v == "-v" {
println("v" + version)
break
}
if v == "--help" || v == "-h" {
println("-i $path$ ", "Read the input path file and parse to html.")
println("-o $path$ ", "Use the input path to write the results in a file.")
println("-p ", "Use paralelism.")
println("-v ", "Show version.")
println("--help -h ", "Show this message.")
}
}
var parsedText = ""
if !isParalel {
parsedText = packs.DefaultPack.Parse(inputText)
} else {
parsedText = packs.DefaultPack.ParalelParse(inputText)
}
if outputPath != "" {
os.WriteFile(outputPath, []byte(parsedText), 0644)
} else if inputText != "" {
println(parsedText)
}
}