Skip to content

Commit 32170f6

Browse files
committed
update CLI (#253)
1 parent e5457fa commit 32170f6

File tree

6 files changed

+56
-10
lines changed

6 files changed

+56
-10
lines changed

happyx.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
description = "Macro-oriented asynchronous web-framework written with ♥"
44
author = "HapticX"
5-
version = "3.9.0"
5+
version = "3.10.0"
66
license = "MIT"
77
srcDir = "src"
88
installExt = @["nim"]

src/happyx/cli/flags_command.nim

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import
2+
./utils
3+
4+
5+
proc flagsCommand*() =
6+
## Shows the general help message that describes
7+
styledEcho "Here is ", fgMagenta, "HappyX", fgWhite, " flags:"
8+
styledEcho " [Flags colors]:"
9+
styledEcho fgMagenta, " for SSG/SSR/SPA"
10+
styledEcho fgCyan, " flags with values"
11+
styledEcho fgYellow, " works with any flags"
12+
styledEcho fgRed, " experimental"
13+
styledEcho " [Main]:"
14+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "httpx", fgWhite, " - switches to HttpX server"
15+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "beast", fgWhite, " - switches to HttpBeast server"
16+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "micro", fgWhite, " - switches to MicroAsyncHttpServer server"
17+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgRed, "translate", fgWhite, " - enables autotranslation (translatable needed)"
18+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgCyan, "cryptoMethod", fgWhite, " - chooses crypto method"
19+
styledEcho " possible values: ", fgYellow, "sha224|sha256|sha384|sha512"
20+
styledEcho " default value: ", fgYellow, "sha512"
21+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgCyan, "numThreads", fgWhite, " - chooses number of threads (for httpx/httpbeast)"
22+
styledEcho " default value: ", fgYellow, "0"
23+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgCyan, "sessionIdLength", fgWhite, " - chooses length of session ID"
24+
styledEcho " default value: ", fgYellow, "32"
25+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "disableApiDoc", fgWhite, " - disable API documentation (swagger and redoc)"
26+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "appName", fgWhite, " - application name (for documentation)"
27+
styledEcho " default value: ", fgYellow, "\"HappyX Application\""
28+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "apiDocsPath", fgWhite, " - docs path (for documentation)"
29+
styledEcho " default value: ", fgYellow, "\"/docs\""
30+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "noliveviews", fgWhite, " - Disables LiveViews at SSR/SSG (It helpful for components)"
31+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "safeRequests", fgWhite, " - Enables requests safety (On error returns 500 with err msg)"
32+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgMagenta, "disableDefDeco", fgWhite, " - Disables default decorators (`AuthBasic`, `GetUserAgent`)"
33+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgYellow, "debug", fgWhite, " - enables HappyX debug"
34+
styledEcho " [DEV]:"
35+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "compDebug", fgWhite, " - enables debug logging for components"
36+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "compTreeDebug", fgWhite, " - enables debug logging for components (tree mode)"
37+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "ssrDebug", fgWhite, " - enables debug logging for SSR"
38+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "spaDebug", fgWhite, " - enables debug logging for SPA"
39+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "reqModelDebug", fgWhite, " - enables debug logging for request models"
40+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "routingDebug", fgWhite, " - enables debug logging for routing"
41+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "componentDebugTarget", fgWhite, " - after this component program will terminated"
42+
styledEcho " ", fgYellow, "-d", fgWhite, ":", fgGreen, "reqModelDebugTarget", fgWhite, " - after this request model program will terminated"

src/happyx/cli/help_command.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ proc mainHelpMessage*() =
1010
## Shows the general help message that describes
1111
let
1212
subcommands = [
13-
"build", "dev", "serve", "create", "html2tag", "update", "info", "help"
13+
"build", "dev", "serve", "create", "html2tag", "update", "info", "flags", "help"
1414
]
1515
logoColors = [
1616
fgBlue, fgGreen, fgYellow, fgWhite, fgCyan

src/happyx/core/constants.nim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
## | `-d:micro` | enables MicroAsyncHttpServer as alternative HTTP Server ⚡ | ❌ |
99
## | `-d:translate` | enables automatic translate for returns 🌐 | ❌ |
1010
## | `-d:debug` | enables debug logging 💻 | ❌ |
11-
## | `-d:oldRenderer` | enables old renderer for SPA 🍍 | ❌ |
1211
## | `-d:cryptoMethod` | choose crypto method for `generate_password` methods 🔐 | ✅ |
1312
## | `-d:numThreads` | choose number of threads (httpx/httpbeast) ⌛ | ✅ |
1413
## | `-d:sessionIdLength` | choose length of session ID ✍ | ✅ |
1514
## | `-d:disableApiDoc` | disables built-in API documentation 📕 | ❌ |
16-
## | `-d:disableORM` | disables built-in ORM 📑 | ❌ |
1715
## | `-d:appName` | choose name of application (SSR/SSG) 📕 | ✅ |
1816
## | `-d:apiDocsPath` | choose path for API documentation 📕 | ✅ |
1917
## | `-d:noliveviews` | Disables LiveViews at SSR/SSG (It helpful for components) 📕 | ❌ |

src/happyx/hpx.nim

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import
1010
create_command, build_command,
1111
dev_command, serve_command,
1212
html2tag_command, help_command,
13-
update_command, project_info_command
13+
update_command, project_info_command,
14+
flags_command
1415
]
1516

1617
import illwill except
@@ -25,6 +26,7 @@ proc html2tagCommandAux(output: string = "", args: seq[string]): int = html2tagC
2526
proc updateCommandAux(args: seq[string]): int = updateCommand(args)
2627
proc serveCommandAux(host: string = "0.0.0.0", port: int = 80): int = serveCommand(host, port)
2728
proc projectInfoCommandAux(): int = projectInfoCommand()
29+
proc flagsCommandAux(): int = flagsCommand()
2830
proc devCommandAux(host: string = "127.0.0.1", port: int = 5000,
2931
reload: bool = false): int =
3032
devCommand(host, port, reload)
@@ -34,6 +36,7 @@ proc createCommandAux(name: string = "", kind: string = "", templates: bool = fa
3436

3537

3638
proc mainCommand(version = false): int =
39+
## HappyX main command
3740
if version:
3841
styledEcho "HappyX ", fgGreen, HpxVersion
3942
else:
@@ -52,6 +55,7 @@ when isMainModule:
5255
[createCommandAux, cmdName = "create"],
5356
[html2tagCommandAux, cmdName = "html2tag"],
5457
[updateCommandAux, cmdName = "update"],
58+
[flagsCommandAux, cmdName = "flags"],
5559
[
5660
mainCommand,
5761
short = {"version": 'v'}
@@ -77,6 +81,8 @@ when isMainModule:
7781
case subcmd
7882
of "build":
7983
quit(dispatchbuild(cmdline = pars[1..^1]))
84+
of "flags":
85+
quit(dispatchflags(cmdline = pars[1..^1]))
8086
of "dev":
8187
quit(dispatchdev(cmdline = pars[1..^1]))
8288
of "serve":
@@ -152,6 +158,10 @@ when isMainModule:
152158
styledEcho "\nUsage:"
153159
styledEcho fgMagenta, " hpx info"
154160
styledEcho fgYellow, "Use ", fgMagenta, "--no-emoji", fgYellow, " flag to disable emoji"
161+
of "flags":
162+
styledEcho fgBlue, "HappyX", fgMagenta, " flags ", fgWhite, "command displays all HappyX Nim flags."
163+
styledEcho "\nUsage:"
164+
styledEcho fgMagenta, " hpx flags"
155165
else:
156166
styledEcho fgRed, "Unknown subcommand: ", fgWhite, subcmdHelp
157167
shutdownCli()

src/happyx/spa/renderer.nim

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,7 @@ else:
262262
when defined(js):
263263
proc renderVdom*(app: App, tag: TagRef, force: bool = false) =
264264
## Rerender DOM with VDOM
265-
# compile with `-d:oldRenderer` to work with old renderer
266-
when enableOldRenderer:
267-
document.getElementById(app.appId).innerHTML = $tag
268-
else:
269-
var realDom = document.getElementById(app.appId).Node
265+
var realDom = document.getElementById(app.appId).Node
270266
realDom.innerHTML = ""
271267
realDom.appendChild(tag)
272268
if force:

0 commit comments

Comments
 (0)