DaemonEngine / Urcheon

An asset builder and package manager for Dæmon based games
https://unvanquished.net
ISC License
12 stars 1 forks source link

Drop StageParse and use argparse.subparsers instead #53

Closed illwieckz closed 2 years ago

illwieckz commented 2 years ago

Drop custom StageParse and use argparse.subparsers instead.

In the process I modified a bit the ordering of some options. The generic options are now to be written before the command keyword (previously named stage).

So instead of:

urcheon prepare --build-prefix /build/path src/*.dpkdir
urcheon build --build-prefix --map-profile nolight /build/path src/*.dpkdir
urcheon package --build-prefix /build/path src/*.dpkdir

One would do:

urcheon --build-prefix /build/path prepare src/*.dpkdir
urcheon --build-prefix /build/path build -map-profile nolight src/*.dpkdir
urcheon --build-prefix /build/path package src/*.dpkdir

Because generic options like --build-prefix or --game are now global options.

For esquirel, only --debug became global.

Of course those commands provide required help like before:

urcheon --help
urcheon <command> --help
esquirel --help
esquirel bsp --help
esquirel map --help
illwieckz commented 2 years ago

I've investigated again ways to implement the ability to do that (something I dream of since I started this project):

urcheon --build-prefix /build/path \
    prepare \
    build -map-profile nolight \
    package \
    src/*.dpkdir

I've got something that was almost working and the only missing feature is to get argparse stop parsing on first unknown argument. Unfortunately it looks like this need is expressed since more than 11 years but I haven't seen it implemented. I may have to implement a fully custom parser at some point to allow that syntax. It's really unfortunate. I miss this syntax for Urcheon since the day I started this project…

Anyway, even if one day I implement a fully custom parser for Urcheon, I'll keep the urcheon <global options> command <command options> dpkdir syntax so I can start with merging this that removes some code.

Also Esquirel is expected to not keep argparse with subparsers because it entirely fills the need.

illwieckz commented 2 years ago

@necessarily-equal @DolceTriade you may want to know about it.

DolceTriade commented 2 years ago

Seems sound