Skip to content

Conversation

andreimerlescu
Copy link
Owner

Added the ability to define an alias using:

figs := figtree.Grow()
figs.NewString("name", "", "Your Name")
figs.WithAlias("name", "n")
figs.Parse()
figs.Usage()

This yields in the usage:

Usage of figtree (powered by figtree v2.0.9):
  -n|-name[=] [String] Your Name

@Copilot Copilot AI review requested due to automatic review settings June 15, 2025 11:37
@andreimerlescu andreimerlescu self-assigned this Jun 15, 2025
@andreimerlescu andreimerlescu added the enhancement New feature or request label Jun 15, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for aliases in the figtree package. Key changes include:

  • Updates to the usage output to show aliases for flags.
  • Addition of a new WithAlias API and corresponding interface changes.
  • Modifications in flag access methods to resolve flag values by alias and removal of deprecated source functionality.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
usage.go Updated Usage() output to include alias flags
types.go Added WithAlias method to the interface definitions
source.go Removed source-related functionality
mutations.go Updated flag retrieval functions to resolve aliases
internals_test.go Updated test structures to initialize aliases
go.mod Upgraded some dependency versions
figtree_test.go Added version and tracking tests
alias_test.go Added tests to validate alias behavior and conflict cases
alias.go Implemented the WithAlias method
VERSION Bumped the project version
Comments suppressed due to low confidence (1)

mutations.go:20

  • The extra call to unlock the mutex in the error branch causes a double unlock because of the deferred tree.mu.RUnlock() at the beginning of the function. Removing the redundant unlock is needed to prevent a runtime panic.
tree.mu.RUnlock()

@andreimerlescu andreimerlescu merged commit 8fb63d9 into main Jun 15, 2025
6 checks passed
@andreimerlescu andreimerlescu deleted the feature/alias branch June 15, 2025 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant