2020-02-20 13:41:03 +01:00
|
|
|
module main
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
const (
|
|
|
|
too_long_line_length = 100
|
|
|
|
)
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
files_paths := os.args[1..]
|
2020-10-20 20:14:56 +02:00
|
|
|
mut warnings := 0
|
2020-02-20 13:41:03 +01:00
|
|
|
mut errors := 0
|
|
|
|
for file_path in files_paths {
|
2020-03-20 16:41:18 +01:00
|
|
|
real_path := os.real_path(file_path)
|
2020-02-20 13:41:03 +01:00
|
|
|
lines := os.read_lines(real_path) or {
|
2020-10-20 20:14:56 +02:00
|
|
|
println('"$file_path" does not exist')
|
|
|
|
warnings++
|
2020-02-20 13:41:03 +01:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
for i, line in lines {
|
|
|
|
if line.len > too_long_line_length {
|
2020-10-20 20:14:56 +02:00
|
|
|
linetrace_msg := '$file_path:${i + 1}:${line.len + 1}: '
|
|
|
|
if line.starts_with('|') {
|
|
|
|
println(linetrace_msg + 'long table (warn)')
|
|
|
|
warnings++
|
|
|
|
} else if line.contains('https') {
|
|
|
|
println(linetrace_msg + 'long link (warn)')
|
|
|
|
warnings++
|
|
|
|
} else {
|
|
|
|
eprintln(linetrace_msg + 'line too long')
|
|
|
|
errors++
|
|
|
|
}
|
2020-02-20 13:41:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-20 20:14:56 +02:00
|
|
|
if warnings > 0 || errors > 0 {
|
|
|
|
println('\nWarnings | Errors')
|
|
|
|
println('$warnings\t | $errors')
|
|
|
|
}
|
2020-02-20 13:41:03 +01:00
|
|
|
if errors > 0 {
|
|
|
|
exit(1)
|
|
|
|
}
|
|
|
|
}
|