mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-03-25 21:40:52 +00:00
This commit refactors the k-mer index management tools to use a unified subcommand structure with obik, adds support for per-set metadata and ID management, enhances the k-mer set group builder to support appending to existing groups, and improves command-line option handling with a new global options registration system. Key changes: - Introduce obik command with subcommands (index, ls, summary, cp, mv, rm, super, lowmask) - Add support for per-set metadata and ID management in kmer set groups - Implement ability to append to existing kmer index groups - Refactor option parsing to use a global options registration system - Add new commands for listing, copying, moving, and removing sets - Enhance low-complexity masking with new options and output formats - Improve kmer index summary with Jaccard distance matrix support - Remove deprecated obikindex and obisuperkmer commands - Update build process to use the new subcommand structure
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package obioptions
|
|
|
|
import (
|
|
"github.com/DavidGamba/go-getoptions"
|
|
)
|
|
|
|
// GenerateSubcommandParser creates an option parser that supports subcommands
|
|
// via go-getoptions' NewCommand/SetCommandFn/Dispatch API.
|
|
//
|
|
// The setup function receives the root *GetOpt and should register subcommands
|
|
// using opt.NewCommand(). Global options (--debug, --max-cpu, etc.) are
|
|
// registered before setup is called and are inherited by all subcommands.
|
|
//
|
|
// Returns the root *GetOpt (needed for Dispatch) and an ArgumentParser
|
|
// that handles parsing and post-parse processing.
|
|
func GenerateSubcommandParser(
|
|
program string,
|
|
documentation string,
|
|
setup func(opt *getoptions.GetOpt),
|
|
) (*getoptions.GetOpt, ArgumentParser) {
|
|
|
|
options := getoptions.New()
|
|
options.Self(program, documentation)
|
|
options.SetMode(getoptions.Bundling)
|
|
options.SetUnknownMode(getoptions.Fail)
|
|
|
|
// Register global options (inherited by all subcommands)
|
|
RegisterGlobalOptions(options)
|
|
|
|
// Let the caller register subcommands
|
|
setup(options)
|
|
|
|
// Add automatic help subcommand (must be after all commands)
|
|
options.HelpCommand("help", options.Description("Show help for a command"))
|
|
|
|
parser := func(args []string) (*getoptions.GetOpt, []string) {
|
|
remaining, err := options.Parse(args[1:])
|
|
ProcessParsedOptions(options, err)
|
|
return options, remaining
|
|
}
|
|
|
|
return options, parser
|
|
}
|