hwylterm/tests/example.nim

62 lines
1.2 KiB
Nim
Raw Normal View History

2024-11-10 01:49:31 -06:00
import std/strformat
import hwylterm/hwylcli
2024-11-10 03:36:19 -06:00
type
Color = enum
red, blue, green
2024-11-10 01:49:31 -06:00
hwylCli:
name "example"
V "0.1.0"
... "a description of hwylterm"
flags:
yes:
T bool
? "set flag to yes"
2024-11-10 03:21:16 -06:00
[global]
2024-11-10 01:49:31 -06:00
config:
T seq[string]
? "path to config file"
* @["config.yml"]
run:
echo "this is always run prior to subcommand parsing"
echo fmt"{yes=}, {config=}"
subcommands:
--- one
... "the first subcommand"
flags:
2024-11-10 03:36:19 -06:00
color:
T Color
? "a color (red, green, blue)"
verbose:
T Count
? "a count flag"
- v
2024-11-10 01:49:31 -06:00
run:
echo "hello from `example one` command!"
2024-11-10 03:36:19 -06:00
echo fmt"{color=}"
echo fmt"{verbose=}"
2024-11-10 01:49:31 -06:00
--- two
... """
some second subcommand
a longer mulitline description that will be visible in the subcommand help
it will automatically be "bb"'ed [bold]this is bold text[/]
"""
flags:
aflag:
T bool
? "some help"
bflag:
T seq[float]
? "multiple floats"
2024-11-10 03:21:16 -06:00
c:
? "this should be a single flag"
h "overwrite the short h from help"
2024-11-10 01:49:31 -06:00
run:
echo "hello from `example b` command"
echo fmt"{aflag=}, {bflag=}"