-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
I defined an argument to parse like so:
private static final String GOV_CONSTANTS_FILEPATH_ARG = "gov-constants";
ArgumentParser parser = ArgumentParsers.newFor("Financial Predictor").build()
.defaultHelp(true)
.description("A financial modelling CLI");
parser.addArgument("--" + GOV_CONSTANTS_FILEPATH_ARG)
.required(true)
.help("YAML file of gov constants per year");
but I was very confused why the following was showing a null value:
String govConstantsFilepath = parsedArgs.getString(GOV_CONSTANTS_FILEPATH_ARG);
LOG.debug("Gov constants filepath: {}", govConstantsFilepath);
When I printed the Namespace object, turns out argparse4j is changing the case of the output:
Namespace: Namespace(gov_constants=gov-constants.yml)
This was very unexpected, and only after some digging did I find the noDestConversionForPositionalArgs flag on the builder. However, even with this flag to true, my --gov-constants flag arg gets registered in the Namespace as gov_constants.
It seems likely most people would reuse a single constant for both defining the argument and retrieving the arg from the namespace, so I'm curious what the rationale is for doing the conversion?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels