Skip to content

Add field selection and table formatting for parse/search commands#101

Merged
digizeph merged 1 commit intomainfrom
fix/issue-99-table-headings
Jan 29, 2026
Merged

Add field selection and table formatting for parse/search commands#101
digizeph merged 1 commit intomainfrom
fix/issue-99-table-headings

Conversation

@digizeph
Copy link
Member

Summary

This PR improves the output formatting for monocle parse and monocle search commands by adding:

  • Field selection (--fields / -f): Choose which columns to display
  • Table formatting: Proper bordered tables when using --format table
  • Better defaults: PSV format for streaming, separate defaults for parse vs search

Changes

  • New --fields option accepts comma-separated field names (e.g., -f prefix,as_path,collector)
  • Table output now uses tabled crate with rounded borders instead of tab-separated values
  • Default format changed to PSV (pipe-separated) for parse/search - works better for streaming large datasets
  • Parse command defaults exclude the collector field (not applicable)
  • Search command defaults include the collector field
  • Markdown format includes proper header row with separator

Available Fields

type, timestamp, peer_ip, peer_asn, prefix, as_path, origin, next_hop, local_pref, med, communities, atomic, aggr_asn, aggr_ip, collector

Examples

# Default PSV output (no headers, streaming-friendly)
monocle search --start-ts 2025-01-01T00:00:00Z --duration 1m -c rrc00

# Table format with borders
monocle search --start-ts 2025-01-01T00:00:00Z --duration 1m -c rrc00 --format table

# Custom field selection
monocle search --start-ts 2025-01-01T00:00:00Z --duration 1m -c rrc00 -f prefix,as_path,collector

# Markdown output
monocle parse some-file.gz --format markdown

Closes #99

- Add --fields (-f) option to parse and search commands for selecting output fields
- Add proper table formatting with borders using tabled crate for --format table
- Change default format for parse/search to PSV (pipe-separated values) for streaming compatibility
- Add markdown format support with header rows
- Separate default fields: parse excludes collector, search includes it
- Collector field only appears when explicitly requested or in search defaults

Closes #99
@digizeph digizeph merged commit 5f2d052 into main Jan 29, 2026
1 check passed
digizeph added a commit that referenced this pull request Jan 29, 2026
- 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
@digizeph digizeph deleted the fix/issue-99-table-headings branch January 31, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output formatting for table/markdown not working

1 participant