lowargs.rs
This file
Path
crates/core/flags/lowargs.rs
735 lines · 25.7 KiB · Rust
Last changed by
cargo: add new build-time `unstable-index` featureAndrew Gallantbefore adoptiond958105
History of this fileTake it
1/*!2Provides the definition of low level arguments from CLI flags.3*/45use std::{6 ffi::{OsStr, OsString},7 path::PathBuf,8};910use {11 bstr::{BString, ByteVec},12 grep::printer::{HyperlinkFormat, UserColorSpec},13};1415/// A collection of "low level" arguments.16///17/// The "low level" here is meant to constrain this type to be as close to the18/// actual CLI flags and arguments as possible. Namely, other than some19/// convenience types to help validate flag values and deal with overrides20/// between flags, these low level arguments do not contain any higher level21/// abstractions.22///23/// Another self-imposed constraint is that populating low level arguments24/// should not require anything other than validating what the user has25/// provided. For example, low level arguments should not contain a26/// `HyperlinkConfig`, since in order to get a full configuration, one needs to27/// discover the hostname of the current system (which might require running a28/// binary or a syscall).29///30/// Low level arguments are populated by the parser directly via the `update`31/// method on the corresponding implementation of the `Flag` trait.32#[derive(Debug, Default)]33pub(crate) struct LowArgs {34 // Essential arguments.35 pub(crate) special: Option<SpecialMode>,36 pub(crate) mode: Mode,37 pub(crate) positional: Vec<OsString>,38 pub(crate) patterns: Vec<PatternSource>,39 // Everything else, sorted lexicographically.40 pub(crate) binary: BinaryMode,41 pub(crate) boundary: Option<BoundaryMode>,42 pub(crate) buffer: BufferMode,43 pub(crate) byte_offset: bool,44 pub(crate) case: CaseMode,45 pub(crate) color: ColorChoice,46 pub(crate) colors: Vec<UserColorSpec>,47 pub(crate) column: Option<bool>,48 pub(crate) context: ContextMode,49 pub(crate) context_separator: ContextSeparator,50 pub(crate) crlf: bool,51 pub(crate) dfa_size_limit: Option<usize>,52 pub(crate) encoding: EncodingMode,53 pub(crate) engine: EngineChoice,54 pub(crate) field_context_separator: FieldContextSeparator,55 pub(crate) field_match_separator: FieldMatchSeparator,56 pub(crate) fixed_strings: bool,57 pub(crate) follow: bool,58 pub(crate) glob_case_insensitive: bool,59 pub(crate) globs: Vec<String>,60 pub(crate) heading: Option<bool>,61 pub(crate) hidden: bool,62 pub(crate) hostname_bin: Option<PathBuf>,63 pub(crate) hyperlink_format: HyperlinkFormat,64 pub(crate) iglobs: Vec<String>,65 pub(crate) ignore_file: Vec<PathBuf>,66 pub(crate) ignore_file_case_insensitive: bool,67 pub(crate) include_zero: bool,68 pub(crate) index: usize,69 pub(crate) index_force: bool,70 pub(crate) index_path: Option<PathBuf>,71 pub(crate) invert_match: bool,72 pub(crate) line_number: Option<bool>,73 pub(crate) logging: Option<LoggingMode>,74 pub(crate) max_columns: Option<u64>,75 pub(crate) max_columns_preview: bool,76 pub(crate) max_count: Option<u64>,77 pub(crate) max_depth: Option<usize>,78 pub(crate) max_filesize: Option<u64>,79 pub(crate) mmap: MmapMode,80 pub(crate) multiline: bool,81 pub(crate) multiline_dotall: bool,82 pub(crate) no_config: bool,83 pub(crate) no_ignore_dot: bool,84 pub(crate) no_ignore_exclude: bool,85 pub(crate) no_ignore_files: bool,86 pub(crate) no_ignore_global: bool,87 pub(crate) no_ignore_messages: bool,88 pub(crate) no_ignore_parent: bool,89 pub(crate) no_ignore_vcs: bool,90 pub(crate) no_messages: bool,91 pub(crate) no_require_git: bool,92 pub(crate) no_unicode: bool,93 pub(crate) null: bool,94 pub(crate) null_data: bool,95 pub(crate) one_file_system: bool,96 pub(crate) only_matching: bool,97 pub(crate) path_separator: Option<u8>,98 pub(crate) pre: Option<PathBuf>,99 pub(crate) pre_glob: Vec<String>,100 pub(crate) quiet: bool,101 pub(crate) regex_size_limit: Option<usize>,102 pub(crate) replace: Option<BString>,103 pub(crate) search_zip: bool,104 pub(crate) sort: Option<SortMode>,105 pub(crate) stats: bool,106 pub(crate) stop_on_nonmatch: bool,107 pub(crate) threads: Option<usize>,108 pub(crate) trim: bool,109 pub(crate) type_changes: Vec<TypeChange>,110 pub(crate) unrestricted: usize,111 pub(crate) vimgrep: bool,112 pub(crate) with_filename: Option<bool>,113}114115/// A "special" mode that supersedes everything else.116///117/// When one of these modes is present, it overrides everything else and causes118/// ripgrep to short-circuit. In particular, we avoid converting low-level119/// argument types into higher level arguments types that can fail for various120/// reasons related to the environment. (Parsing the low-level arguments can121/// fail too, but usually not in a way that can't be worked around by removing122/// the corresponding arguments from the CLI command.) This is overall a hedge123/// to ensure that version and help information are basically always available.124#[derive(Clone, Copy, Debug, Eq, PartialEq)]125pub(crate) enum SpecialMode {126 /// Show a condensed version of "help" output. Generally speaking, this127 /// shows each flag and an extremely terse description of that flag on128 /// a single line. This corresponds to the `-h` flag.129 HelpShort,130 /// Shows a very verbose version of the "help" output. The docs for some131 /// flags will be paragraphs long. This corresponds to the `--help` flag.132 HelpLong,133 /// Show condensed version information. e.g., `ripgrep x.y.z`.134 VersionShort,135 /// Show verbose version information. Includes "short" information as well136 /// as features included in the build.137 VersionLong,138 /// Show PCRE2's version information, or an error if this version of139 /// ripgrep wasn't compiled with PCRE2 support.140 VersionPCRE2,141}142143/// The overall mode that ripgrep should operate in.144///145/// If ripgrep were designed without the legacy of grep, these would probably146/// be sub-commands? Perhaps not, since they aren't as frequently used.147///148/// The point of putting these in one enum is that they are all mutually149/// exclusive and override one another.150///151/// Note that -h/--help and -V/--version are not included in this because152/// they always overrides everything else, regardless of where it appears153/// in the command line. They are treated as "special" modes that short-circuit154/// ripgrep's usual flow.155#[derive(Clone, Copy, Debug, Eq, PartialEq)]156pub(crate) enum Mode {157 /// ripgrep will execute a search of some kind.158 Search(SearchMode),159 /// Create or update a search index.160 Index(IndexMode),161 /// Show the files that *would* be searched, but don't actually search162 /// them.163 Files,164 /// List all file type definitions configured, including the default file165 /// types and any additional file types added to the command line.166 Types,167 /// Generate various things like the man page and completion files.168 Generate(GenerateMode),169}170171impl Default for Mode {172 fn default() -> Mode {173 Mode::Search(SearchMode::Standard)174 }175}176177impl Mode {178 /// Update this mode to the new mode while implementing various override179 /// semantics. For example, a search mode cannot override a non-search180 /// mode.181 pub(crate) fn update(&mut self, new: Mode) {182 match *self {183 // If we're in a search mode, then anything can override it.184 Mode::Search(_) => *self = new,185 _ => {186 // Once we're in a non-search mode, other non-search modes187 // can override it. But search modes cannot. So for example,188 // `--files -l` will still be Mode::Files.189 if !matches!(*self, Mode::Search(_)) {190 *self = new;191 }192 }193 }194 }195}196197/// The kind of index operation that ripgrep should perform.198#[derive(Clone, Copy, Debug, Eq, PartialEq)]199pub(crate) enum IndexMode {200 /// Add, update or remove files in an index.201 Crud,202}203204/// The kind of search that ripgrep is going to perform.205#[derive(Clone, Copy, Debug, Eq, PartialEq)]206pub(crate) enum SearchMode {207 /// The default standard mode of operation. ripgrep looks for matches and208 /// prints them when found.209 ///210 /// There is no specific flag for this mode since it's the default. But211 /// some of the modes below, like JSON, have negation flags like --no-json212 /// that let you revert back to this default mode.213 Standard,214 /// Show files containing at least one match.215 FilesWithMatches,216 /// Show files that don't contain any matches.217 FilesWithoutMatch,218 /// Show files containing at least one match and the number of matching219 /// lines.220 Count,221 /// Show files containing at least one match and the total number of222 /// matches.223 CountMatches,224 /// Print matches in a JSON lines format.225 JSON,226}227228/// The thing to generate via the --generate flag.229#[derive(Clone, Copy, Debug, Eq, PartialEq)]230pub(crate) enum GenerateMode {231 /// Generate the raw roff used for the man page.232 Man,233 /// Completions for bash.234 CompleteBash,235 /// Completions for zsh.236 CompleteZsh,237 /// Completions for fish.238 CompleteFish,239 /// Completions for PowerShell.240 CompletePowerShell,241}242243/// Indicates how ripgrep should treat binary data.244#[derive(Debug, Default, Eq, PartialEq)]245pub(crate) enum BinaryMode {246 /// Automatically determine the binary mode to use. Essentially, when247 /// a file is searched explicitly, then it will be searched using the248 /// `SearchAndSuppress` strategy. Otherwise, it will be searched in a way249 /// that attempts to skip binary files as much as possible. That is, once250 /// a file is classified as binary, searching will immediately stop.251 #[default]252 Auto,253 /// Search files even when they have binary data, but if a match is found,254 /// suppress it and emit a warning.255 ///256 /// In this mode, `NUL` bytes are replaced with line terminators. This is257 /// a heuristic meant to reduce heap memory usage, since true binary data258 /// isn't line oriented. If one attempts to treat such data as line259 /// oriented, then one may wind up with impractically large lines. For260 /// example, many binary files contain very long runs of NUL bytes.261 SearchAndSuppress,262 /// Treat all files as if they were plain text. There's no skipping and no263 /// replacement of `NUL` bytes with line terminators.264 AsText,265}266267/// Indicates what kind of boundary mode to use (line or word).268#[derive(Debug, Eq, PartialEq)]269pub(crate) enum BoundaryMode {270 /// Only allow matches when surrounded by line boundaries.271 Line,272 /// Only allow matches when surrounded by word boundaries.273 Word,274}275276/// Indicates the buffer mode that ripgrep should use when printing output.277///278/// The default is `Auto`.279#[derive(Debug, Default, Eq, PartialEq)]280pub(crate) enum BufferMode {281 /// Select the buffer mode, 'line' or 'block', automatically based on282 /// whether stdout is connected to a tty.283 #[default]284 Auto,285 /// Flush the output buffer whenever a line terminator is seen.286 ///287 /// This is useful when wants to see search results more immediately,288 /// for example, with `tail -f`.289 Line,290 /// Flush the output buffer whenever it reaches some fixed size. The size291 /// is usually big enough to hold many lines.292 ///293 /// This is useful for maximum performance, particularly when printing294 /// lots of results.295 Block,296}297298/// Indicates the case mode for how to interpret all patterns given to ripgrep.299///300/// The default is `Sensitive`.301#[derive(Debug, Default, Eq, PartialEq)]302pub(crate) enum CaseMode {303 /// Patterns are matched case sensitively. i.e., `a` does not match `A`.304 #[default]305 Sensitive,306 /// Patterns are matched case insensitively. i.e., `a` does match `A`.307 Insensitive,308 /// Patterns are automatically matched case insensitively only when they309 /// consist of all lowercase literal characters. For example, the pattern310 /// `a` will match `A` but `A` will not match `a`.311 Smart,312}313314/// Indicates whether ripgrep should include color/hyperlinks in its output.315///316/// The default is `Auto`.317#[derive(Debug, Default, Eq, PartialEq)]318pub(crate) enum ColorChoice {319 /// Color and hyperlinks will never be used.320 Never,321 /// Color and hyperlinks will be used only when stdout is connected to a322 /// tty.323 #[default]324 Auto,325 /// Color will always be used.326 Always,327 /// Color will always be used and only ANSI escapes will be used.328 ///329 /// This only makes sense in the context of legacy Windows console APIs.330 /// At time of writing, ripgrep will try to use the legacy console APIs331 /// if ANSI coloring isn't believed to be possible. This option will force332 /// ripgrep to use ANSI coloring.333 Ansi,334}335336impl ColorChoice {337 /// Convert this color choice to the corresponding termcolor type.338 pub(crate) fn to_termcolor(&self) -> termcolor::ColorChoice {339 match *self {340 ColorChoice::Never => termcolor::ColorChoice::Never,341 ColorChoice::Auto => termcolor::ColorChoice::Auto,342 ColorChoice::Always => termcolor::ColorChoice::Always,343 ColorChoice::Ansi => termcolor::ColorChoice::AlwaysAnsi,344 }345 }346}347348/// Indicates the line context options ripgrep should use for output.349///350/// The default is no context at all.351#[derive(Debug, Eq, PartialEq)]352pub(crate) enum ContextMode {353 /// All lines will be printed. That is, the context is unbounded.354 Passthru,355 /// Only show a certain number of lines before and after each match.356 Limited(ContextModeLimited),357}358359impl Default for ContextMode {360 fn default() -> ContextMode {361 ContextMode::Limited(ContextModeLimited::default())362 }363}364365impl ContextMode {366 /// Set the "before" context.367 ///368 /// If this was set to "passthru" context, then it is overridden in favor369 /// of limited context with the given value for "before" and `0` for370 /// "after."371 pub(crate) fn set_before(&mut self, lines: usize) {372 match *self {373 ContextMode::Passthru => {374 *self = ContextMode::Limited(ContextModeLimited {375 before: Some(lines),376 after: None,377 both: None,378 })379 }380 ContextMode::Limited(ContextModeLimited {381 ref mut before,382 ..383 }) => *before = Some(lines),384 }385 }386387 /// Set the "after" context.388 ///389 /// If this was set to "passthru" context, then it is overridden in favor390 /// of limited context with the given value for "after" and `0` for391 /// "before."392 pub(crate) fn set_after(&mut self, lines: usize) {393 match *self {394 ContextMode::Passthru => {395 *self = ContextMode::Limited(ContextModeLimited {396 before: None,397 after: Some(lines),398 both: None,399 })400 }401 ContextMode::Limited(ContextModeLimited {402 ref mut after, ..403 }) => *after = Some(lines),404 }405 }406407 /// Set the "both" context.408 ///409 /// If this was set to "passthru" context, then it is overridden in favor410 /// of limited context with the given value for "both" and `None` for411 /// "before" and "after".412 pub(crate) fn set_both(&mut self, lines: usize) {413 match *self {414 ContextMode::Passthru => {415 *self = ContextMode::Limited(ContextModeLimited {416 before: None,417 after: None,418 both: Some(lines),419 })420 }421 ContextMode::Limited(ContextModeLimited {422 ref mut both, ..423 }) => *both = Some(lines),424 }425 }426427 /// A convenience function for use in tests that returns the limited428 /// context. If this mode isn't limited, then it panics.429 #[cfg(test)]430 pub(crate) fn get_limited(&self) -> (usize, usize) {431 match *self {432 ContextMode::Passthru => unreachable!("context mode is passthru"),433 ContextMode::Limited(ref limited) => limited.get(),434 }435 }436}437438/// A context mode for a finite number of lines.439///440/// Namely, this indicates that a specific number of lines (possibly zero)441/// should be shown before and/or after each matching line.442///443/// Note that there is a subtle difference between `Some(0)` and `None`. In the444/// former case, it happens when `0` is given explicitly, where as `None` is445/// the default value and occurs when no value is specified.446///447/// `both` is only set by the -C/--context flag. The reason why we don't just448/// set before = after = --context is because the before and after context449/// settings always take precedent over the -C/--context setting, regardless of450/// order. Thus, we need to keep track of them separately.451#[derive(Debug, Default, Eq, PartialEq)]452pub(crate) struct ContextModeLimited {453 before: Option<usize>,454 after: Option<usize>,455 both: Option<usize>,456}457458impl ContextModeLimited {459 /// Returns the specific number of contextual lines that should be shown460 /// around each match. This takes proper precedent into account, i.e.,461 /// that `before` and `after` both partially override `both` in all cases.462 ///463 /// By default, this returns `(0, 0)`.464 pub(crate) fn get(&self) -> (usize, usize) {465 let (mut before, mut after) =466 self.both.map(|lines| (lines, lines)).unwrap_or((0, 0));467 // --before and --after always override --context, regardless468 // of where they appear relative to each other.469 if let Some(lines) = self.before {470 before = lines;471 }472 if let Some(lines) = self.after {473 after = lines;474 }475 (before, after)476 }477}478479/// Represents the separator to use between non-contiguous sections of480/// contextual lines.481///482/// The default is `--`.483#[derive(Clone, Debug, Eq, PartialEq)]484pub(crate) struct ContextSeparator(Option<BString>);485486impl Default for ContextSeparator {487 fn default() -> ContextSeparator {488 ContextSeparator(Some(BString::from("--")))489 }490}491492impl ContextSeparator {493 /// Create a new context separator from the user provided argument. This494 /// handles unescaping.495 pub(crate) fn new(os: &OsStr) -> anyhow::Result<ContextSeparator> {496 let Some(string) = os.to_str() else {497 anyhow::bail!(498 "separator must be valid UTF-8 (use escape sequences \499 to provide a separator that is not valid UTF-8)"500 )501 };502 Ok(ContextSeparator(Some(Vec::unescape_bytes(string).into())))503 }504505 /// Creates a new separator that instructs the printer to disable contextual506 /// separators entirely.507 pub(crate) fn disabled() -> ContextSeparator {508 ContextSeparator(None)509 }510511 /// Return the raw bytes of this separator.512 ///513 /// If context separators were disabled, then this returns `None`.514 ///515 /// Note that this may return a `Some` variant with zero bytes.516 pub(crate) fn into_bytes(self) -> Option<Vec<u8>> {517 self.0.map(|sep| sep.into())518 }519}520521/// The encoding mode the searcher will use.522///523/// The default is `Auto`.524#[derive(Debug, Default, Eq, PartialEq)]525pub(crate) enum EncodingMode {526 /// Use only BOM sniffing to auto-detect an encoding.527 #[default]528 Auto,529 /// Use an explicit encoding forcefully, but let BOM sniffing override it.530 Some(grep::searcher::Encoding),531 /// Use no explicit encoding and disable all BOM sniffing. This will532 /// always result in searching the raw bytes, regardless of their533 /// true encoding.534 Disabled,535}536537/// The regex engine to use.538///539/// The default is `Default`.540#[derive(Debug, Default, Eq, PartialEq)]541pub(crate) enum EngineChoice {542 /// Uses the default regex engine: Rust's `regex` crate.543 ///544 /// (Well, technically it uses `regex-automata`, but `regex-automata` is545 /// the implementation of the `regex` crate.)546 #[default]547 Default,548 /// Dynamically select the right engine to use.549 ///550 /// This works by trying to use the default engine, and if the pattern does551 /// not compile, it switches over to the PCRE2 engine if it's available.552 Auto,553 /// Uses the PCRE2 regex engine if it's available.554 PCRE2,555}556557/// The field context separator to use to between metadata for each contextual558/// line.559///560/// The default is `-`.561#[derive(Clone, Debug, Eq, PartialEq)]562pub(crate) struct FieldContextSeparator(BString);563564impl Default for FieldContextSeparator {565 fn default() -> FieldContextSeparator {566 FieldContextSeparator(BString::from("-"))567 }568}569570impl FieldContextSeparator {571 /// Create a new separator from the given argument value provided by the572 /// user. Unescaping it automatically handled.573 pub(crate) fn new(os: &OsStr) -> anyhow::Result<FieldContextSeparator> {574 let Some(string) = os.to_str() else {575 anyhow::bail!(576 "separator must be valid UTF-8 (use escape sequences \577 to provide a separator that is not valid UTF-8)"578 )579 };580 Ok(FieldContextSeparator(Vec::unescape_bytes(string).into()))581 }582583 /// Return the raw bytes of this separator.584 ///585 /// Note that this may return an empty `Vec`.586 pub(crate) fn into_bytes(self) -> Vec<u8> {587 self.0.into()588 }589}590591/// The field match separator to use to between metadata for each matching592/// line.593///594/// The default is `:`.595#[derive(Clone, Debug, Eq, PartialEq)]596pub(crate) struct FieldMatchSeparator(BString);597598impl Default for FieldMatchSeparator {599 fn default() -> FieldMatchSeparator {600 FieldMatchSeparator(BString::from(":"))601 }602}603604impl FieldMatchSeparator {605 /// Create a new separator from the given argument value provided by the606 /// user. Unescaping it automatically handled.607 pub(crate) fn new(os: &OsStr) -> anyhow::Result<FieldMatchSeparator> {608 let Some(string) = os.to_str() else {609 anyhow::bail!(610 "separator must be valid UTF-8 (use escape sequences \611 to provide a separator that is not valid UTF-8)"612 )613 };614 Ok(FieldMatchSeparator(Vec::unescape_bytes(string).into()))615 }616617 /// Return the raw bytes of this separator.618 ///619 /// Note that this may return an empty `Vec`.620 pub(crate) fn into_bytes(self) -> Vec<u8> {621 self.0.into()622 }623}624625/// The type of logging to do. `Debug` emits some details while `Trace` emits626/// much more.627#[derive(Debug, Eq, PartialEq)]628pub(crate) enum LoggingMode {629 Debug,630 Trace,631}632633/// Indicates when to use memory maps.634///635/// The default is `Auto`.636#[derive(Debug, Default, Eq, PartialEq)]637pub(crate) enum MmapMode {638 /// This instructs ripgrep to use heuristics for selecting when to and not639 /// to use memory maps for searching.640 #[default]641 Auto,642 /// This instructs ripgrep to always try memory maps when possible. (Memory643 /// maps are not possible to use in all circumstances, for example, for644 /// virtual files.)645 AlwaysTryMmap,646 /// Never use memory maps under any circumstances. This includes even647 /// when multi-line search is enabled where ripgrep will read the entire648 /// contents of a file on to the heap before searching it.649 Never,650}651652/// Represents a source of patterns that ripgrep should search for.653///654/// The reason to unify these is so that we can retain the order of `-f/--flag`655/// and `-e/--regexp` flags relative to one another.656#[derive(Debug, Eq, PartialEq)]657pub(crate) enum PatternSource {658 /// Comes from the `-e/--regexp` flag.659 Regexp(String),660 /// Comes from the `-f/--file` flag.661 File(PathBuf),662}663664/// The sort criteria, if present.665#[derive(Debug, Eq, PartialEq)]666pub(crate) struct SortMode {667 /// Whether to reverse the sort criteria (i.e., descending order).668 pub(crate) reverse: bool,669 /// The actual sorting criteria.670 pub(crate) kind: SortModeKind,671}672673/// The criteria to use for sorting.674#[derive(Debug, Eq, PartialEq)]675pub(crate) enum SortModeKind {676 /// Sort by path.677 Path,678 /// Sort by last modified time.679 LastModified,680 /// Sort by last accessed time.681 LastAccessed,682 /// Sort by creation time.683 Created,684}685686impl SortMode {687 /// Checks whether the selected sort mode is supported. If it isn't, an688 /// error (hopefully explaining why) is returned.689 pub(crate) fn supported(&self) -> anyhow::Result<()> {690 match self.kind {691 SortModeKind::Path => Ok(()),692 SortModeKind::LastModified => {693 let md = std::env::current_exe()694 .and_then(|p| p.metadata())695 .and_then(|md| md.modified());696 let Err(err) = md else { return Ok(()) };697 anyhow::bail!(698 "sorting by last modified isn't supported: {err}"699 );700 }701 SortModeKind::LastAccessed => {702 let md = std::env::current_exe()703 .and_then(|p| p.metadata())704 .and_then(|md| md.accessed());705 let Err(err) = md else { return Ok(()) };706 anyhow::bail!(707 "sorting by last accessed isn't supported: {err}"708 );709 }710 SortModeKind::Created => {711 let md = std::env::current_exe()712 .and_then(|p| p.metadata())713 .and_then(|md| md.created());714 let Err(err) = md else { return Ok(()) };715 anyhow::bail!(716 "sorting by creation time isn't supported: {err}"717 );718 }719 }720 }721}722723/// A single instance of either a change or a selection of one ripgrep's724/// file types.725#[derive(Debug, Eq, PartialEq)]726pub(crate) enum TypeChange {727 /// Clear the given type from ripgrep.728 Clear { name: String },729 /// Add the given type definition (name and glob) to ripgrep.730 Add { def: String },731 /// Select the given type for filtering.732 Select { name: String },733 /// Select the given type for filtering but negate it.734 Negate { name: String },735}