@@ -39,44 +39,84 @@ pub fn main() {
3939 <> "!" ,
4040 )
4141 case process . argv ( ) |> array . to_list ( ) |> list . drop ( 2 ) {
42- [ "dynamic" , .. ] ->
43- dynamic_site_server ( mutable_model_type . new ( ) ) |> promise . resolve
42+ [ "dynamic" , .. ] | [ "host" , .. ] ->
43+ dynamic_site_server ( mutable_model_type . new ( ) , 60_000 ) |> promise . resolve
44+ [ "preview" , .. ] ->
45+ dynamic_site_server ( mutable_model_type . new ( ) , 20 ) |> promise . resolve
4446 [ "pregenerate" , .. ] | [ "static" ] -> static_site_server ( )
45- [ "help" , .. ] | [ "--help" , .. ] | [ "-h" , .. ] -> {
47+ [ "init" , .. ] | [ "initialise" , .. ] -> {
48+ config . initcfg ( )
49+ |> promise . resolve
50+ }
51+ [ "help" , .. ] | [ "--help" , .. ] | [ "-h" , .. ] | [ ] -> {
52+ case process . argv ( ) |> array . to_list ( ) |> list . drop ( 2 ) {
53+ [ ] -> console . error ( "No subcommand given.\n " )
54+ _ -> Nil
55+ }
4656 console . log (
47- "\n Cynthia Mini - A lightweight server for building websites \n \n "
57+ "\n Cynthia Website Engine Mini - Creating websites from simple files \n \n "
4858 <> "Usage:\n "
49- <> " cynthia-mini [command]\n \n "
59+ <> premixed . text_bright_cyan ( "\t cynthiaweb-mini" )
60+ <> " "
61+ <> premixed . text_bright_orange ( "[command]" )
62+ <> " \n "
5063 <> "Commands:\n "
51- <> " dynamic Start a dynamic website server\n "
52- <> " static Generate a static website\n "
53- <> " pregenerate Alias for static\n "
54- <> " help Show this help message\n \n "
55- <> "For more information, visit: https://github.com/CynthiaWebsiteEngine/Mini" ,
64+ // Init:
65+ <> string . concat ( [
66+ premixed . text_pink ( "\t init" ) ,
67+ " | " ,
68+ premixed . text_pink ( "initialise\n " ) ,
69+ ] )
70+ <> "\t \t \t \t Initialise the config file then exit\n \n "
71+ // Dynamic:
72+ <> string . concat ( [
73+ premixed . text_pink ( "\t dynamic" ) ,
74+ " | " ,
75+ premixed . text_pink ( "host\n " ) ,
76+ ] )
77+ <> "\t \t \t \t Start a dynamic website server\n \n "
78+ // Pregenerate:
79+ <> string . concat ( [
80+ premixed . text_pink ( "\t static" ) ,
81+ " | " ,
82+ premixed . text_pink ( "pregenerate\n " ) ,
83+ ] )
84+ <> "\t \t \t \t Generate a static website\n \n "
85+ // Preview:
86+ <> premixed . text_pink ( "\t preview\n " )
87+ <> "\t \t \t \t Start a dynamic website server for previewing\n "
88+ <> "\t \t \t \t this is the same as dynamic, but with a shorter\n "
89+ <> "\t \t \t \t interval for the cache\n \n "
90+ // Help:
91+ <> premixed . text_lilac ( "\t help" )
92+ <> "\n "
93+ <> "\t \t \t \t Show this help message\n \n "
94+ <> "For more information, visit: "
95+ <> premixed . text_blue (
96+ "https://cynthiawebsiteengine.github.io/Mini-docs" ,
97+ )
98+ <> ".\n " ,
5699 )
57100 |> promise . resolve
58101 }
59102 [ a , .. ] | [ a ] ->
60103 console . error (
61- "Unknown subcommand: ´"
104+ premixed . text_error_red ( "Unknown subcommand: " )
105+ <> "´"
62106 <> premixed . text_bright_orange ( a )
63- <> "´. Please try with "
64- <> premixed . text_green ( "´dynamic´" )
65- <> " or "
66- <> premixed . text_green ( "´static´" )
67- <> " instead." ,
68- )
69- |> promise . resolve
70-
71- [ ] ->
72- console . error (
73- "No subcommand given. Please try with ´dynamic´ or ´static´ instead." ,
107+ <> "´. Please try with ´"
108+ <> premixed . text_green ( "dynamic" )
109+ <> "´ or ´"
110+ <> premixed . text_green ( "static" )
111+ <> "´ instead. Or use ´"
112+ <> premixed . text_purple ( "help" )
113+ <> "´ to see a list of all subcommands.\n " ,
74114 )
75115 |> promise . resolve
76116 }
77117}
78118
79- fn dynamic_site_server ( mutmodel : mutable_model_type . MutableModel ) {
119+ fn dynamic_site_server ( mutmodel : mutable_model_type . MutableModel , lease : Int ) {
80120 console . info ( "Cynthia Mini is in dynamic site mode!" )
81121 let model = mutmodel |> mutable_reference . get
82122 let conf = model . config
@@ -145,7 +185,7 @@ fn dynamic_site_server(mutmodel: mutable_model_type.MutableModel) {
145185 <> "/" ,
146186 ) ,
147187 )
148- global . set_interval ( 60_000 , fn ( ) {
188+ global . set_interval ( lease , fn ( ) {
149189 mutable_reference . update ( mutmodel , fn ( model ) {
150190 case model . cached_response {
151191 None -> model
0 commit comments