summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/main.go27
-rw-r--r--internal/build/build.go42
2 files changed, 47 insertions, 22 deletions
diff --git a/cmd/main.go b/cmd/main.go
index afef7bb..e60dbb7 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
"path/filepath"
+ "strings"
internal "github.com/HimanshuSardana/kite/internal/build"
)
@@ -53,30 +54,12 @@ func main() {
case "build":
internal.Build()
case "list-themes":
- themeList := make([]string, 0)
- themes, err := os.ReadDir("../themes/")
- if err != nil {
- log.Fatal("Error:", err)
- }
- for _, theme := range themes {
- if theme.IsDir() {
- themeList = append(themeList, string(theme.Name()))
- }
- }
+ themeList := internal.ListThemes()
+ fmt.Println(strings.Join(themeList, "\n"))
default:
- showHelpMessage()
+ internal.ShowHelpMessage()
}
} else {
- showHelpMessage()
+ internal.ShowHelpMessage()
}
}
-
-func showHelpMessage() {
- fmt.Println(`
-Usage: kite <SUBCOMMAND>
-
-SUBCOMMANDS:
-build
-serve
-`)
-}
diff --git a/internal/build/build.go b/internal/build/build.go
index 1fe85b3..74dda4e 100644
--- a/internal/build/build.go
+++ b/internal/build/build.go
@@ -238,3 +238,45 @@ func renderHomePage(summaries []PostSummary, outputDir string) {
}
fmt.Println("Home page written to", outPath)
}
+
+func ListThemes() []string {
+ themeList := make([]string, 0)
+ themes, err := os.ReadDir("./themes")
+ if err != nil {
+ log.Fatal("Error:", err)
+ }
+ for _, theme := range themes {
+ if theme.IsDir() {
+ themeList = append(themeList, string(theme.Name()))
+ }
+ }
+
+ return themeList
+}
+
+func ShowHelpMessage() {
+ fmt.Println(`
+Kite — A lightweight static site generator
+
+USAGE:
+ kite <command> [options]
+
+COMMANDS:
+ build Build the static site into the output directory
+ serve Start a local development server with live reload
+ list-themes List all available themes
+
+OPTIONS:
+ -h, --help Show this help message
+
+EXAMPLES:
+ kite build
+ kite serve
+ kite serve --port 8080
+ kite list-themes
+
+DESCRIPTION:
+ Kite converts your content into a static website using themes and templates.
+ Use 'build' for production output and 'serve' for local development.
+`)
+}