Blesmol / pfscf

Pathfinder Society Chronicle Filler
https://blesmol.github.io/pfscf/
MIT License
7 stars 3 forks source link

Automatically choose blank chronicle PDF file matching the scenario #96

Open Blesmol opened 3 years ago

Blesmol commented 3 years ago

Allow to configure a path for blank chronicles. In that path, look whether a file exists with the same filename as the required template, e.g. "pfs2.s1-15.pdf". If so and if nothing else was specified on the command line, use that file automatically.

tdhsmith commented 3 years ago

Was working on this, but it brings up a tricky argument parsing question: when the command also has key-value pair arguments, how do you determine whether an infile is provided or not? Or more specifically, how do you determine if an argument is a file vs a parameter. My basic logic was to check for presence of an equals sign, but strictly speaking = is not restricted on modern filesystems (though some, like DOS-compatible ones, might choke on it).

So reject filenames with equals signs? Or change the overall argument structure?

tdhsmith commented 3 years ago

Update: ok this might not be a problem for batch fill -- is that command supposed to allow additional parameters? The command line help seems to suggest it, and there's code for parsing them, but the requirement defined via cobra is exactly 3 arguments.

Blesmol commented 3 years ago

Perhaps I'm missing the point, but I currently do not see any problems.

Currently the subcommands expect some positional parameters, like the name of the CSV file, the template ID etc. Besides that, there is a framework in place to provide and recognize additional arguments starting with --, e.g. --examples, or their short form, e.g. -e. All other provided arguments are currently expected to have the format <key>=<value>, and that is the only thing that really needs to be "parsed" here.

But what does this have to do with automatically choosing the correct blank chronicle PDF?

Assume that providing the input file is, as described in one of the other issues, switched over to optional argument, i.e. something like --input=<my_file>. The framework will filter this out, so there won't be any conflicts. And if the parameter is not provided on the command line by the user, a lookup on the FS can be made. For example something like "does /chronicles/pfs2.s1-23.pdf exist?" if the user specified that he wants to fill a sheet for scenario #1-23.

So reject filenames with equals signs?

At the moment I would assume that even then this should work without problems with the current code.

Blesmol commented 3 years ago

PS: Handling of the command line flags is currently done in the pfscf/cmd/cmd*.go files if you want to have a look.