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 log
|
||||
import time
|
||||
import regex
|
||||
import markdown
|
||||
import internal.template
|
||||
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{
|
||||
name: 'build'
|
||||
description: 'build your site'
|
||||
|
|
|
@ -8,7 +8,8 @@ import internal.config
|
|||
|
||||
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{
|
||||
name: 'serve'
|
||||
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
|
||||
}
|
||||
|
||||
// load
|
||||
// load config from toml text
|
||||
pub fn load(toml_text string) !Config {
|
||||
doc := toml.parse_text(toml_text)!
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module template
|
||||
|
||||
// parse template with target
|
||||
pub fn parse(template string, target map[string]string) string {
|
||||
mut content := template
|
||||
for key in target.keys() {
|
||||
|
|
22
main.v
22
main.v
|
@ -1,7 +1,27 @@
|
|||
module main
|
||||
|
||||
import os
|
||||
import cli
|
||||
import commands
|
||||
|
||||
const version = '0.3.0'
|
||||
|
||||
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