file を検索する機能の追加

This commit is contained in:
zztkm 2022-07-26 01:55:59 +09:00
parent f77aa916de
commit 2579bda3d8

34
vss.v
View file

@ -2,23 +2,37 @@ module main
import os
import cli
import markdown
fn main() {
mut app := cli.Command {
name: "vss"
version: "0.0.0"
description: "static site generator"
mut app := cli.Command{
name: 'vss'
version: '0.0.0'
description: 'static site generator'
execute: fn (cmd cli.Command) ? {
paths := get_paths("docs")
for path in paths {
println(path)
}
return
}
}
text := '# Markdown Rocks!'
output := markdown.to_html(text)
println(output) // <h1>Markdown Rocks!</h1>
text := '# Markdown Rocks!'
output := markdown.to_html(text)
println(output) // <h1>Markdown Rocks!</h1>
app.setup()
app.parse(os.args)
}
// work の検証をやる
https://modules.vlang.io/os.html#walk
fn normalise_paths(paths []string) []string {
mut res := paths.map(it.replace(os.path_separator, '/'))
res.sort()
return res
}
fn get_paths(path string) []string {
mds := os.walk_ext(path, '.md')
return mds
}