-
Notifications
You must be signed in to change notification settings - Fork 7
Porting Guide
How to port your code from seqan3::argument_parser
to the sharg::parser
Go to the seqan3 submodules and update to current master (or release once seqan3 with sharg was released)
cd app/dir/lib/seqan3 # path where the seqan3submodule lives
git pull origin master
git submodule update --init
Now you should be able to use the sharg parser. You can test if it worked by including a sharg header without using it.
// somehwere inside a hpp or cpp file
#include <sharg/all.hpp>
Change the namespace of all argument parsing related entities from seqan3::
to sharg::
.
The following classes have to be renamed:
-
seqan3::argument_parser
->sharg::parser
-
seqan3::argument_parser_error
->sharg::parser_error
-
seqan3::argument_parsing
->sharg::parsing
(CPO for customised option values, e.g. enumeration_names CPO) -
seqan3::argument_parser_compatible_option
->sharg::parser_compatible_option
(concept, usually not used directly)
This will be the most work. Sorry for that, but we hope that it will be easier and more flexible in the future.
Instead of multiple parameters, the parser.add_[...]
calls will take a value and a sharg::config
object
Before:
parser.add_option(val, 'i', "int", "some int");
Now:
parser.add_option(val, sharg::config{.short_id = 'i', .long_id = "int", .description = "some int"});
here is a full config option for each add_[...]()
call. You can adapt or delete the members you need
add_option
my_parser.add_option(my_value,
sharg::config{.short_id = 'i',
.long_id = "int",
.description = "some description.",
.required = false,
.advanced = false,
.hidden = false,
.validator = sharg::arithmetic_validator{0,2}});
add_flag
my_parser.add_flag(my_value,
sharg::config{.short_id = 'i',
.long_id = "int",
.description = "some description.",
.advanced = false,
.hidden = false);
add_positional_option
my_parser.add_positional_option(my_value,
sharg::config{.description = "some description.",
.validator = sharg::arithmetic_validator{0,2}});
sharg::config
API documentation is here.
(Note that the documentation isn't detailed yet. It will become more detailed after feedback from you)