2018-01-08 21:03:00 +01:00
|
|
|
package main
|
|
|
|
|
|
2018-01-08 23:07:05 +01:00
|
|
|
type checkSyntaxOptions struct {
|
2018-01-08 22:06:41 +01:00
|
|
|
command *commandOptions
|
|
|
|
|
syntax *fileOptions
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-08 21:03:00 +01:00
|
|
|
func checkSyntax(args []string) int {
|
2018-01-08 23:07:05 +01:00
|
|
|
var o checkSyntaxOptions
|
2018-01-09 01:03:19 +01:00
|
|
|
o.command = initOptions(checkSyntaxUsage, checkSyntaxExample, positionalSyntaxUsage, args)
|
|
|
|
|
o.syntax = &fileOptions{typ: "syntax", flagSet: o.command.flagSet, positionalDoc: positionalSyntaxUsage}
|
2018-01-08 22:06:41 +01:00
|
|
|
|
2018-01-09 01:03:19 +01:00
|
|
|
o.command.stringFlag(&o.syntax.inline, "syntax-string", syntaxStringUsage)
|
|
|
|
|
o.command.stringFlag(&o.syntax.fileName, "syntax", syntaxFileUsage)
|
2018-01-08 22:06:41 +01:00
|
|
|
|
2018-01-09 00:21:35 +01:00
|
|
|
if o.command.help() {
|
2018-01-08 21:03:00 +01:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-08 22:06:41 +01:00
|
|
|
if code := o.command.parseArgs(); code != 0 {
|
2018-01-08 21:03:00 +01:00
|
|
|
return code
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-08 22:06:41 +01:00
|
|
|
o.syntax.positional = o.command.flagSet.Args()
|
2018-01-08 23:07:05 +01:00
|
|
|
_, code := o.syntax.openSyntax()
|
2018-01-08 21:03:00 +01:00
|
|
|
return code
|
|
|
|
|
}
|