Skip to content

Finish the initial argument class #3

@Bijaelo

Description

@Bijaelo

This issue is a simple checklist to keep track of the progress of the "argument" class.

The first version is going to be a "rough" but "complete" sketch that can handle the standard input types, in a similar but not identical manner to the python argparse module.

For this the argument needs to

  • Accept cmdline flags (at least 1 and 2, but possibly more)
  • Be knowing of their own name
  • Have knowledge of how to be restrictive to a certain range of argument count (narg)
  • Be able to handle how to be a required argument, and its interaction onto narg
  • Be able to be a flag, and have methods for handling being the best flag that it can be
  • Be able to carry a default value, and know how this should be handled (specifically its interaction with required and narg)
  • Should have knowledge of different possible actions and their effect on other parameters (such as store_const, append_const, store and so forth)
  • Note that with R's data structures some changes makes sense here
  • Be able to handle const values (with specific actions)
  • Be able to restrict itself to only a set of choices
  • It should be able to contain a parser.func (an R function) which can be used to parse the arguments
  • It should obviously be able to parse its own arguments, eg. have knowledge of how to call parser.func and this
  • later on we'll look at handling help messages, meta variables, etc. But for this I think I'll split the class into different children (the plan has not been sketched yet).
  • again later I should implement some standard methods for "integer", "double" and "string" (the latter returns "as is") to avoid the repeated call to the R api (as much as possible).
  • Shortly after implementation is done it should be able to handle a call to R's as function, and be able to test if a string is a valid function. The method should be
    1. Test if parser_func is a function, if so use it
    2. Test if parser_func is a string, if not throw error
    3. Test that parser_func string is within builtin methods (once implemented) if so, use it
    4. Test that parser_func string is an actual function using get_function (using Rf_findFun from R.h, see Rcpp::Function)
    5. If everything else fails create a call to the R function as, using the S4 method for coerce.

This should ensure somewhat optimal speeds.

The argument should not necessarily need to know whether it is a "positional" argument, as this is handled by the parser itself. Help message formatting, meta data and so on should come in once everything else is setup, classes are split into sub methods and so on.

Note that the argument of argparse type is redefined as parser.func (or parser_func in Cpp), as this is a more apt naming for the input.

Metadata

Metadata

Assignees

Labels

featurepackage featurein-developmentThis label indicates that the issue is about something intended to be standard within the package

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions