hwylterm/tests/example.nim

76 lines
1.5 KiB
Nim
Raw Normal View History

2024-11-10 11:36:59 -06:00
import std/[strformat, strutils]
import hwylterm, hwylterm/hwylcli
2024-11-10 01:49:31 -06:00
2024-11-10 03:36:19 -06:00
type
Color = enum
red, blue, green
2024-11-10 11:36:59 -06:00
2024-11-10 01:49:31 -06:00
hwylCli:
name "example"
V "0.1.0"
... "a description of hwylterm"
flags:
2024-11-10 11:36:59 -06:00
[global]
2024-11-10 01:49:31 -06:00
yes:
T bool
? "set flag to yes"
[shared]
something:
? "some flag only needed in one subcommand"
config:
2024-11-10 01:49:31 -06:00
T seq[string]
? "path to config file"
* @["config.yml"]
2024-11-10 11:36:59 -06:00
preSub:
echo "this is run after subcommand parsing but before its run block"
2024-11-10 01:49:31 -06:00
run:
echo "this is always run prior to subcommand parsing"
subcommands:
[onelonger]
2024-11-10 11:36:59 -06:00
... """
the first subcommand
this command features both an enum flag and a Count flag
it also inherits the `[[shared]` flag group
2024-11-10 11:36:59 -06:00
"""
2024-11-12 17:29:12 -06:00
alias o,"one", `one-l`
2024-11-10 01:49:31 -06:00
flags:
2024-11-10 03:36:19 -06:00
color:
T Color
? "a color (red, green, blue)"
verbose:
T Count
? "a count flag"
- v
^[shared]
2024-11-10 01:49:31 -06:00
run:
echo "hello from `example one` command!"
2024-11-10 16:19:44 -06:00
echo args
2024-11-10 03:36:19 -06:00
echo fmt"{color=}"
echo fmt"{verbose=}"
2024-11-10 11:36:59 -06:00
echo fmt"{config=}"
2024-11-10 01:49:31 -06:00
["two-longer"]
2024-11-10 01:49:31 -06:00
... """
some second subcommand
a longer mulitline description that will be visible in the subcommand help
2024-11-10 11:36:59 -06:00
and it will automatically be "bb"'ed [bold]this is bold text[/]
2024-11-10 01:49:31 -06:00
"""
flags:
^something
auto:
- a
2024-11-10 01:49:31 -06:00
? "some help"
2024-11-10 11:36:59 -06:00
b:
2024-11-10 01:49:31 -06:00
T seq[float]
? "multiple floats"
2024-11-10 11:36:59 -06:00
h "this will override the builtin 'h' for help"
2024-11-10 01:49:31 -06:00
run:
echo "hello from `example b` command"
echo fmt"{auto=}, {b=}"
2024-11-10 01:49:31 -06:00