Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for filtering of output. #171

Closed
wants to merge 17 commits into from
Closed

Conversation

terjekv
Copy link
Collaborator

@terjekv terjekv commented Aug 31, 2023

  • Command output may be filtered by | followed by whitespace and a regular expression (or a simple string).
  • The regular expression is applied to each line of output, and only lines that match are displayed.
  • The expression may be negated by using |! instead of |.
  • Substitution is not supported.

Examples:

  • network list_used_addresses 172.16.20.0 | bl23-.*mu2[17] will output only lines matching the regular expression.
  • network list_used_addresses 172.16.20.0 |! mu2[17] will output only lines not matching the regular expression.

This applies all commands that output to the console, but it does not apply to errors, warnings, or informational messages. This allows filters to be used without concern for missing important information.

@terjekv terjekv self-assigned this Aug 31, 2023
  - Command output may be filtered by `|` followed by whitespace and a regular expression (or a simple string).
  - The regular expression is applied to each line of output, and only lines that match are displayed.
  - The expression may be negated by using `|!` instead of `|`.
  - Substitution is not supported.
@terjekv terjekv marked this pull request as draft August 31, 2023 18:38

if filter_str.startswith("!"):
negate = True
filter_str = filter_str[1:].strip()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This strip is superflous as it has already been stripped. Just need the [1:].

@oyvindkolbu
Copy link
Collaborator

You are mixing functial and formatting changes. Makes review very hard.

@terjekv
Copy link
Collaborator Author

terjekv commented Sep 1, 2023

Yeah. Sadly my editor setup is strict with PEPs. I'll try to review the settings for the project for every copy of the repo I work on. In general though I'm tempted to do a pure formatting PR towards black and isort, and adding them to a lint job.

terjekv added a commit to terjekv/mreg-cli that referenced this pull request Nov 12, 2023
  - Command output may be filtered by `|` followed by whitespace and a regular expression (or a simple string).
  - The regular expression is applied to each line of output, and only lines that match are displayed.
  - The expression may be negated by using `|!` instead of `|`.
  - Substitution is not supported.

Examples:

- `network list_used_addresses 172.16.20.0 | bl23-.*mu2[17]` will output only lines matching the regular expression.
- `network list_used_addresses 172.16.20.0 |! mu2[17]` will output only lines *not* matching the regular expression.

This applies all commands that output to the console, but it does *not* apply to errors, warnings, or informational messages. This allows filters to be used without concern for missing important information.

This is a cleaner Singleton-based implementation of unioslo#171.
@terjekv
Copy link
Collaborator Author

terjekv commented Nov 13, 2023

Superseded by a much better implementation in #174.

@terjekv terjekv closed this Nov 13, 2023
terjekv added a commit to terjekv/mreg-cli that referenced this pull request Nov 23, 2023
  - Command output may be filtered by `|` followed by whitespace and a regular expression (or a simple string).
  - The regular expression is applied to each line of output, and only lines that match are displayed.
  - The expression may be negated by using `|!` instead of `|`.
  - Substitution is not supported.

Examples:

- `network list_used_addresses 172.16.20.0 | bl23-.*mu2[17]` will output only lines matching the regular expression.
- `network list_used_addresses 172.16.20.0 |! mu2[17]` will output only lines *not* matching the regular expression.

This applies all commands that output to the console, but it does *not* apply to errors, warnings, or informational messages. This allows filters to be used without concern for missing important information.

This is a cleaner Singleton-based implementation of unioslo#171.
terjekv added a commit that referenced this pull request Nov 24, 2023
* feat: Allow for filtering of output

  - Command output may be filtered by `|` followed by whitespace and a regular expression (or a simple string).
  - The regular expression is applied to each line of output, and only lines that match are displayed.
  - The expression may be negated by using `|!` instead of `|`.
  - Substitution is not supported.

Examples:

- `network list_used_addresses 172.16.20.0 | bl23-.*mu2[17]` will output only lines matching the regular expression.
- `network list_used_addresses 172.16.20.0 |! mu2[17]` will output only lines *not* matching the regular expression.

This applies all commands that output to the console, but it does *not* apply to errors, warnings, or informational messages. This allows filters to be used without concern for missing important information.

This is a cleaner Singleton-based implementation of #171.
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.

2 participants