merged vss.v into main.v
the impact of this. - change factory func to public
This commit is contained in:
parent
9805052fa1
commit
3be9a7ed53
6 changed files with 27 additions and 26 deletions
|
@ -4,7 +4,6 @@ import os
|
||||||
import cli
|
import cli
|
||||||
import log
|
import log
|
||||||
import time
|
import time
|
||||||
import regex
|
|
||||||
import markdown
|
import markdown
|
||||||
import internal.template
|
import internal.template
|
||||||
import internal.config
|
import internal.config
|
||||||
|
@ -37,7 +36,8 @@ fn new_builder(logger log.Log) Builder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_build_cmd() cli.Command {
|
// new_build_cmd returns a cli.Command for build command
|
||||||
|
pub fn new_build_cmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
name: 'build'
|
name: 'build'
|
||||||
description: 'build your site'
|
description: 'build your site'
|
||||||
|
|
|
@ -8,7 +8,8 @@ import internal.config
|
||||||
|
|
||||||
const cport = 8080
|
const cport = 8080
|
||||||
|
|
||||||
fn new_serve_cmd() cli.Command {
|
// new_serve_cmd returns a cli.Command for serve command
|
||||||
|
pub fn new_serve_cmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
name: 'serve'
|
name: 'serve'
|
||||||
description: 'serve dist'
|
description: 'serve dist'
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
module commands
|
|
||||||
|
|
||||||
import os
|
|
||||||
import cli
|
|
||||||
|
|
||||||
pub fn execute() {
|
|
||||||
mut app := cli.Command{
|
|
||||||
name: 'vss'
|
|
||||||
version: '0.3.0'
|
|
||||||
description: 'static site generator'
|
|
||||||
execute: fn (cmd cli.Command) ! {
|
|
||||||
println(cmd.help_message())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
app.add_command(new_build_cmd())
|
|
||||||
app.add_command(new_serve_cmd())
|
|
||||||
|
|
||||||
app.setup()
|
|
||||||
app.parse(os.args)
|
|
||||||
}
|
|
|
@ -20,7 +20,7 @@ pub mut:
|
||||||
base_url string
|
base_url string
|
||||||
}
|
}
|
||||||
|
|
||||||
// load
|
// load config from toml text
|
||||||
pub fn load(toml_text string) !Config {
|
pub fn load(toml_text string) !Config {
|
||||||
doc := toml.parse_text(toml_text)!
|
doc := toml.parse_text(toml_text)!
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
module template
|
module template
|
||||||
|
|
||||||
|
// parse template with target
|
||||||
pub fn parse(template string, target map[string]string) string {
|
pub fn parse(template string, target map[string]string) string {
|
||||||
mut content := template
|
mut content := template
|
||||||
for key in target.keys() {
|
for key in target.keys() {
|
||||||
|
|
22
main.v
22
main.v
|
@ -1,7 +1,27 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
|
import os
|
||||||
|
import cli
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
|
const version = '0.3.0'
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
commands.execute()
|
mut app := cli.Command{
|
||||||
|
name: 'vss'
|
||||||
|
version: version
|
||||||
|
description: 'static site generator'
|
||||||
|
execute: fn (cmd cli.Command) ! {
|
||||||
|
println(cmd.help_message())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add commands
|
||||||
|
app.add_command(commands.new_build_cmd())
|
||||||
|
app.add_command(commands.new_serve_cmd())
|
||||||
|
|
||||||
|
app.setup()
|
||||||
|
|
||||||
|
// run the app
|
||||||
|
app.parse(os.args)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue