-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (53 loc) · 1.39 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
package main
import (
"github.com/shiranr/linkcheck/models"
"github.com/shiranr/linkcheck/utils"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"os"
"path/filepath"
"runtime"
"time"
)
// TODO add tests.
// TODO add workflow
// TODO add support for link description [](link "")
// TODO fix readme
// TODO mock external server behavior
func main() {
start := time.Now()
log.SetLevel(log.InfoLevel)
_, b, _, _ := runtime.Caller(0)
basepath := filepath.Dir(b)
configPath := basepath + "/configuration/linkcheck.json"
var app = &cli.App{
Name: "linkcheck",
Usage: "A linter in Golang to verify Markdown links.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config",
Value: configPath,
Usage: "configuration file",
Destination: &configPath,
},
},
Version: "1.0.0",
Action: func(ctx *cli.Context) error {
configPath = ctx.String("config")
utils.LoadConfiguration(configPath)
var readmeFiles []string
log.Info("Context first argument " + ctx.Args().First())
if ctx.Args().Present() {
readmeFiles = utils.ExtractMarkdownFilesFromList(ctx.Args().Slice())
} else {
readmeFiles = utils.ExtractMarkdownFiles()
}
return models.GetFilesProcessorInstance().Process(readmeFiles)
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
end := time.Now()
log.Info("Time elapsed: " + end.Sub(start).String())
}