The Nushell documentation references an inc command that was designed to increment values, including semantic version strings:
- Documentation: https://www.nushell.sh/commands/docs/inc.html
- Supported flags:
--major,--minor,--patch
The inc command was available in Nushell versions prior to 0.80 but has been moved to a plugin in current versions (0.107.0+).
The inc functionality is now available as an official Nushell plugin: nu_plugin_inc
cargo install nu_plugin_inc# Start nushell
nu
# Register the plugin
plugin add ~/.cargo/bin/nu_plugin_inc
# Or in one command:
nu -c "plugin add ~/.cargo/bin/nu_plugin_inc"nu -c '"1.2.3" | inc --patch'
# Should output: 1.2.4The scripts/bump-version.nu script now uses a hybrid approach:
- First, try to use the
incplugin if it's installed and registered - Fallback to custom implementation if the plugin is not available
This ensures the script works whether or not the plugin is installed, while preferring the official plugin when available.
def bump_semver [
version: string
bump_type: string
]: nothing -> string {
# Try to use inc plugin if available
let inc_result = try {
match $bump_type {
"major" => { $version | inc --major }
"minor" => { $version | inc --minor }
"patch" => { $version | inc --patch }
}
} catch {
null
}
# If inc plugin worked, return the result
if $inc_result != null {
return $inc_result
}
# Fallback to custom implementation
# [custom implementation code]
}- Plugin-first approach: Uses official nu_plugin_inc when available
- Graceful fallback: Works without the plugin for compatibility
- No manual configuration: Script detects and uses the plugin automatically
- Best of both worlds: Official plugin + guaranteed functionality
When the plugin is installed:
- ✅ Uses official, maintained code from the Nushell team
- ✅ Consistent with Nushell ecosystem
- ✅ Automatically updated with plugin updates
- ✅ Better integration with Nushell's type system
- With plugin: Uses
nu_plugin_inc(recommended) - Without plugin: Uses custom implementation (automatic fallback)
- Both approaches: Produce identical results
To use the plugin in CI/CD environments, add to your setup:
- name: Install nu_plugin_inc
run: |
cargo install nu_plugin_inc
nu -c "plugin add ~/.cargo/bin/nu_plugin_inc"The script now follows best practices by:
- Preferring the official
nu_plugin_incwhen available - Providing a fallback for environments without the plugin
- Automatically detecting and using the appropriate method
- Requiring no changes to the command-line interface