feat(command): add #[Group] and #[SingleInstance] attributes#55
Merged
Conversation
- Add WebFiori\Cli\Attributes\Group attribute for help display grouping - Add WebFiori\Cli\Attributes\SingleInstance attribute for lock-based single-instance enforcement - Add LockManager class using flock() for non-blocking exclusive locks - Add getGroup()/setGroup() to Command - Add resolveGroup() with precedence: explicit > attribute > colon convention - Integrate SingleInstance into excCommand() with try/finally lock release - Update HelpCommand to display commands in groups when present - Establish WebFiori\Cli\Attributes\ namespace per ADR-0025 Closes #47 Closes #49
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #55 +/- ##
============================================
+ Coverage 88.08% 88.36% +0.27%
- Complexity 1317 1350 +33
============================================
Files 34 37 +3
Lines 3768 3858 +90
============================================
+ Hits 3319 3409 +90
Misses 449 449
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Introduce PHP 8.1 attributes for command metadata, establishing the
WebFiori\Cli\Attributes\namespace per ADR-0025.Motivation
Closes #47, Closes #49.
Changes
New files
WebFiori/Cli/Attributes/Group.php—#[Group("name")]for help display groupingWebFiori/Cli/Attributes/SingleInstance.php—#[SingleInstance]for lock-based concurrency preventionWebFiori/Cli/LockManager.php— flock-based non-blocking exclusive locks with PID trackingModified files
Command.php— addedgroupproperty,getGroup()/setGroup(),resolveGroup(),resolveSingleInstance(), integrated lock intoexcCommand()with try/finallyRunner.php— callsresolveGroup()on registerHelpCommand.php— grouped output when groups exist (alphabetical, ungrouped last)Resolution precedence (Group):
setGroup()(programmatic)#[Group]attributedb:migrate→db)SingleInstance behavior:
exec(), released infinallylockPathandexitCodesupportedHow to Test / Verify
tests/WebFiori/Tests/Cli/LockManagerTest.php(7 tests)tests/WebFiori/Tests/Cli/CommandAttributesTest.php(12 tests)Run:
composer testBreaking Changes and Migration Steps
None. Commands without attributes behave exactly as before.
Checklist
composer fix-cs)Related issues
Closes #47
Closes #49