From 3be9a7ed53f1c5c27f4e40b1f1f10c47c3a1b755 Mon Sep 17 00:00:00 2001 From: zztkm Date: Mon, 7 Aug 2023 08:03:23 +0900 Subject: [PATCH] merged vss.v into main.v the impact of this. - change factory func to public --- commands/build.v | 4 ++-- commands/serve.v | 3 ++- commands/vss.v | 21 --------------------- internal/config/config.v | 2 +- internal/template/template.v | 1 + main.v | 22 +++++++++++++++++++++- 6 files changed, 27 insertions(+), 26 deletions(-) delete mode 100644 commands/vss.v diff --git a/commands/build.v b/commands/build.v index 02de135..f45de6d 100644 --- a/commands/build.v +++ b/commands/build.v @@ -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' diff --git a/commands/serve.v b/commands/serve.v index 046fcfb..6faf90d 100644 --- a/commands/serve.v +++ b/commands/serve.v @@ -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' diff --git a/commands/vss.v b/commands/vss.v deleted file mode 100644 index 303efee..0000000 --- a/commands/vss.v +++ /dev/null @@ -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) -} diff --git a/internal/config/config.v b/internal/config/config.v index d68349c..2fdc2fb 100644 --- a/internal/config/config.v +++ b/internal/config/config.v @@ -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)! diff --git a/internal/template/template.v b/internal/template/template.v index 2868b7c..073d79a 100644 --- a/internal/template/template.v +++ b/internal/template/template.v @@ -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() { diff --git a/main.v b/main.v index 7ebf9f2..4898211 100644 --- a/main.v +++ b/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) }