feat: add --order-by and --order parameters to parse and search commands#102
Merged
feat: add --order-by and --order parameters to parse and search commands#102
Conversation
- Add OrderByField enum with sortable fields: timestamp, prefix, peer_ip, peer_asn, as_path, next_hop - Add OrderDirection enum with asc/desc options - Add sort_elems() function for sorting buffered BGP elements - Update parse command to buffer and sort output when ordering is requested - Update search command to buffer and sort output when ordering is requested - Update CHANGELOG.md with unreleased changes for #98 and #101 When --order-by is specified, output is buffered before display to enable sorting. This allows users to view results in chronological or reverse chronological order. Closes #98
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
This PR adds sorting capability to the
parseandsearchcommands, allowing users to output results in a specified order (e.g., chronological or reverse chronological).Closes #98
Changes
--order-byoption to specify the field to sort by--orderoption to specify sort direction (asc/desc, default: asc)Available Order-By Fields
timestamp- Order by timestamp (default)prefix- Order by network prefixpeer_ip- Order by peer IP addresspeer_asn- Order by peer AS numberas_path- Order by AS path (string comparison)next_hop- Order by next hop IP addressExamples
Notes
peer_ip,as_path) to match the output field names--order-byis specified, all output is buffered before display (similar to table format behavior)--order-by, streaming output behavior is preserved for better performance with large datasets