mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 03:50:39 +00:00
⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5" - Update version.txt from 4.29 → .30 (automated by Makefile)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# OBIOptions Package: Global Command-Line Interface Utilities
|
||||
|
||||
The `obioptions` package provides shared command-line argument parsing and runtime configuration for OBITools4 commands. It centralizes common options, logging setup, profiling controls, and taxonomy handling.
|
||||
|
||||
## Core Functionalities
|
||||
|
||||
- **Global Option Registration**: `RegisterGlobalOptions()` defines shared flags such as:
|
||||
- `--version`, `--debug`
|
||||
- CPU/thread control (`--max-cpu`)
|
||||
- Batch processing parameters: `--batch-size`, `-size-max`, `--batch-mem`
|
||||
- Quality encoding (`--solexa`)
|
||||
- Warning suppression (`--silent-warning`)
|
||||
|
||||
- **Option Processing**: `ProcessParsedOptions()` handles post-parsing logic:
|
||||
- Prints help/version and exits on request
|
||||
- Loads default taxonomy via `obiformats.LoadTaxonomy()`
|
||||
- Configures log level (debug/info)
|
||||
- Starts `pprof` HTTP servers for performance profiling:
|
||||
- Generic (`/debug/pprof`)
|
||||
- Mutex contention (`--pprof-mutex`, `runtime.SetMutexProfileFraction()`)
|
||||
- Goroutine blocking (`--pprof-goroutine`, `runtime.SetBlockProfileRate()`)
|
||||
|
||||
- **Parser Generator**: `GenerateOptionParser()` builds a reusable argument parser with:
|
||||
- Bundled short options (`-abc`)
|
||||
- Strict unknown-option handling
|
||||
- Automatic `--help` support
|
||||
|
||||
## Taxonomy Integration
|
||||
|
||||
- `LoadTaxonomyOptionSet()` registers taxonomy-specific flags:
|
||||
- Required/optional path to DB (`--taxonomy`, `-t`)
|
||||
- Alternative names search (`--alternative-names`)
|
||||
- Taxonomic validation: `--fail-on-taxonomy`, automatic updates via `--update-taxid`
|
||||
- Raw taxID output (`--raw-taxid`)
|
||||
- Leaf sequences inclusion via `--with-leaves`
|
||||
|
||||
## Runtime Accessors
|
||||
|
||||
- `CLIIsDebugMode()`, `SeqAsTaxa()` → read current state
|
||||
- `SetDebugOn/Off()` → programmatic debug toggling
|
||||
|
||||
## Design Principles
|
||||
|
||||
- Environment variable support (`OBIMAXCPU`, `OBIWARNING`, etc.)
|
||||
- Thread-safe taxonomy loading with mutex
|
||||
- Graceful error handling (parse errors → help + exit)
|
||||
- Integration with `logrus` and Go’s standard profiling tools
|
||||
@@ -0,0 +1,23 @@
|
||||
# Semantic Description of `GenerateSubcommandParser`
|
||||
|
||||
The function `GenerateSubcommandParser` constructs a command-line argument parser with support for **subcommands**, leveraging the `go-getoptions` library.
|
||||
|
||||
- It accepts:
|
||||
- `program`: The program name (used for help/version).
|
||||
- `documentation`: A top-level description of the tool.
|
||||
- `setup`: A callback to register subcommands and their options.
|
||||
|
||||
- Internally:
|
||||
- Initializes a `GetOpt` instance with bundling mode (`-abc`) and strict unknown-option handling.
|
||||
- Registers **global options** (e.g., `--debug`, `--verbose`) that are inherited by all subcommands.
|
||||
- Invokes the user-provided `setup` function to define **subcommand-specific options and commands**.
|
||||
- Automatically adds a built-in `help` subcommand for command-level documentation.
|
||||
|
||||
- Returns:
|
||||
- The root `*GetOpt`, required to invoke `.Dispatch()`.
|
||||
- An `ArgumentParser` function (signature: `func([]string) (*GetOpt, []string)`), which:
|
||||
- Parses command-line arguments (skipping `args[0]`, typically the binary name),
|
||||
- Handles errors via `ProcessParsedOptions`,
|
||||
- Returns parsed state and remaining positional arguments.
|
||||
|
||||
This design enables a clean, hierarchical CLI structure: global flags → subcommands → per-command options/positional args.
|
||||
@@ -0,0 +1,35 @@
|
||||
# OBIOptions Package – Semantic Description
|
||||
|
||||
The `obioptions` package provides a lightweight, version-aware utility for the OBITools suite. Its core functionality is centered around exposing runtime version information in a standardized and programmatic way.
|
||||
|
||||
## Key Features
|
||||
|
||||
- **Version Exposure**:
|
||||
Exposes the current version of OBITools via a simple, read-only function `VersionString()`. This allows other modules or external tools to query the package version at runtime.
|
||||
|
||||
- **Automated Versioning**:
|
||||
The `_Version` variable is automatically populated from an external `version.txt` file during the build process (via Makefile), ensuring consistency between source metadata and compiled artifacts.
|
||||
|
||||
- **Patch-Level Tracking**:
|
||||
The version follows semantic conventions (`MAJOR.MINOR.PATCH`), with the patch number incremented automatically on each repository push—enabling precise tracking of development iterations.
|
||||
|
||||
- **No Side Effects**:
|
||||
The `VersionString()` function is pure: it takes no parameters and performs only a string return, making it safe for use in logging, diagnostics, or compatibility checks.
|
||||
|
||||
- **Documentation Ready**:
|
||||
Includes inline GoDoc comments for clarity and tooling support (e.g., `go doc`), improving maintainability.
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Debugging and logging (e.g., including version in error reports).
|
||||
- Conditional logic based on OBITools compatibility.
|
||||
- CI/CD validation (e.g., verifying deployed version matches expectations).
|
||||
|
||||
## Version Format
|
||||
|
||||
`"Release X.Y.Z"` (e.g., `"Release 4.4.29"`), where:
|
||||
- `X` = Major release (breaking changes),
|
||||
- `Y` = Minor release (new features, backward-compatible),
|
||||
- `Z` = Patch level (incremented per push for hotfixes/bug fixes).
|
||||
|
||||
No external dependencies or configuration required.
|
||||
Reference in New Issue
Block a user