text stringlengths 9 39.2M | dir stringlengths 26 295 | lang stringclasses 185
values | created_date timestamp[us] | updated_date timestamp[us] | repo_name stringlengths 1 97 | repo_full_name stringlengths 7 106 | star int64 1k 183k | len_tokens int64 1 13.8M |
|---|---|---|---|---|---|---|---|---|
```javascript
var App = new Vue({
el: "#app",
data() {
return {
search: "",
title: "Game of Thrones",
cards: [
{
name: "Season One",
cardColor: "dark",
items: [
"winter is coming",
"the kingsroad",
"lord snow",
... | /content/code_sandbox/js/kanban.js | javascript | 2016-07-30T20:50:30 | 2024-08-14T11:31:01 | bulma-templates | BulmaTemplates/bulma-templates | 3,257 | 870 |
```javascript
document.querySelectorAll("#nav li").forEach(function(navEl) {
navEl.onclick = function() { toggleTab(this.id, this.dataset.target); }
});
function toggleTab(selectedNav, targetId) {
var navEls = document.querySelectorAll("#nav li");
navEls.forEach(function(navEl) {
if (navEl.id == selectedNav... | /content/code_sandbox/js/tabs.js | javascript | 2016-07-30T20:50:30 | 2024-08-14T11:31:01 | bulma-templates | BulmaTemplates/bulma-templates | 3,257 | 167 |
```javascript
// The following code is based off a toggle menu by @Bradcomp
// source: path_to_url
(function() {
var burger = document.querySelector('.burger');
var menu = document.querySelector('#'+burger.dataset.target);
burger.addEventListener('click', function() {
burger.classList.toggle('is-act... | /content/code_sandbox/js/bulma.js | javascript | 2016-07-30T20:50:30 | 2024-08-14T11:31:01 | bulma-templates | BulmaTemplates/bulma-templates | 3,257 | 75 |
```rust
fn main() {
set_git_revision_hash();
set_windows_exe_options();
}
/// Embed a Windows manifest and set some linker options.
///
/// The main reason for this is to enable long path support on Windows. This
/// still, I believe, requires enabling long path support in the registry. But
/// if that's enabl... | /content/code_sandbox/build.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 462 |
```toml
max_width = 79
use_small_heuristics = "max"
``` | /content/code_sandbox/rustfmt.toml | toml | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 16 |
```rust
use std::time;
use serde_derive::Deserialize;
use serde_json as json;
use crate::hay::{SHERLOCK, SHERLOCK_CRLF};
use crate::util::{Dir, TestCommand};
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
#[serde(tag = "type", content = "data")]
#[serde(rename_all = "snake_case")]
enum Message {
Begin(Begin... | /content/code_sandbox/tests/json.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,799 |
```rust
#[macro_export]
macro_rules! rgtest {
($name:ident, $fun:expr) => {
#[test]
fn $name() {
let (dir, cmd) = crate::util::setup(stringify!($name));
$fun(dir, cmd);
if cfg!(feature = "pcre2") {
let (dir, cmd) = crate::util::setup_pcre2(stringi... | /content/code_sandbox/tests/macros.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 294 |
```rust
// Macros useful for testing.
#[macro_use]
mod macros;
// Corpora.
mod hay;
// Utilities for making tests nicer to read and easier to write.
mod util;
// Tests for ripgrep's handling of binary files.
mod binary;
// Tests related to most features in ripgrep. If you're adding something new
// to ripgrep, tests ... | /content/code_sandbox/tests/tests.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 135 |
```rust
use std::env;
use std::error;
use std::ffi::OsStr;
use std::fs::{self, File};
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process::{self, Command};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread;
use std::time::Duration;
use bstr::ByteSlice;
static TEST_DIR: &'static ... | /content/code_sandbox/tests/util.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,375 |
```rust
use crate::hay::{SHERLOCK, SHERLOCK_CRLF};
use crate::util::{sort_lines, Dir, TestCommand};
// See: path_to_url
rgtest!(f1_sjis, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes(
"foo",
b"\x84Y\x84u\x84\x82\x84|\x84\x80\x84{ \x84V\x84\x80\x84|\x84}\x84\x83"
);
cmd.arg("-Esjis").a... | /content/code_sandbox/tests/feature.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 10,138 |
```rust
use crate::util::{Dir, TestCommand};
// This file contains a smattering of tests specifically for checking ripgrep's
// handling of binary files. There's quite a bit of discussion on this in this
// bug report: path_to_url
// Our haystack is the first 500 lines of Gutenberg's copy of "A Study in
// Scarlet," ... | /content/code_sandbox/tests/binary.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 3,054 |
```rust
pub const SHERLOCK: &'static str = "\
For the Doctor Watsons of this world, as opposed to the Sherlock
Holmeses, success in the province of detective work must always
be, to a very large extent, the result of luck. Sherlock Holmes
can extract a clew from a wisp of straw or a flake of cigar ash;
but Doctor Watso... | /content/code_sandbox/tests/hay.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 212 |
```rust
use crate::hay::SHERLOCK;
use crate::util::{Dir, TestCommand};
// This tests that multiline matches that span multiple lines, but where
// multiple matches may begin and end on the same line work correctly.
rgtest!(overlap1, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "xxx\nabc\ndefxxxabc\ndefxxx... | /content/code_sandbox/tests/multiline.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,098 |
```rust
use crate::hay::SHERLOCK;
use crate::util::{cmd_exists, sort_lines, Dir, TestCommand};
// This file contains "miscellaneous" tests that were either written before
// features were tracked more explicitly, or were simply written without
// linking them to a specific issue number. We should try to minimize the
/... | /content/code_sandbox/tests/misc.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 9,982 |
```shell
#!/bin/bash
# Various utility functions used through CI.
# Finds Cargo's `OUT_DIR` directory from the most recent build.
#
# This requires one parameter corresponding to the target directory
# to search for the build output.
cargo_out_dir() {
# This works by finding the most recent stamp file, which is p... | /content/code_sandbox/ci/utils.sh | shell | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 530 |
```ruby
class RipgrepBin < Formula
version '14.1.0'
desc "Recursively search directories for a regex pattern."
homepage "path_to_url"
if OS.mac?
url "path_to_url#{version}/ripgrep-#{version}-x86_64-apple-darwin.tar.gz"
sha256 your_sha256_hash
elsif OS.linux?
url "path_to_url#{version}/ripgr... | /content/code_sandbox/pkg/brew/ripgrep-bin.rb | ruby | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 178 |
```rust
use crate::hay::SHERLOCK;
use crate::util::{sort_lines, Dir, TestCommand};
// See: path_to_url
rgtest!(r16, |dir: Dir, mut cmd: TestCommand| {
dir.create_dir(".git");
dir.create(".gitignore", "ghi/");
dir.create_dir("ghi");
dir.create_dir("def/ghi");
dir.create("ghi/toplevel.txt", "xyz");
... | /content/code_sandbox/tests/regression.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 10,633 |
```rust
use {
grep_matcher::ByteSet,
regex_syntax::{
hir::{self, Hir, HirKind, Look},
utf8::Utf8Sequences,
},
};
/// Return a confirmed set of non-matching bytes from the given expression.
pub(crate) fn non_matching_bytes(expr: &Hir) -> ByteSet {
let mut set = ByteSet::full();
remov... | /content/code_sandbox/crates/regex/src/non_matching.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,336 |
```rust
/// An error that can occur in this crate.
///
/// Generally, this error corresponds to problems building a regular
/// expression, whether it's in parsing, compilation or a problem with
/// guaranteeing a configured optimization.
#[derive(Clone, Debug)]
pub struct Error {
kind: ErrorKind,
}
impl Error {
... | /content/code_sandbox/crates/regex/src/error.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 727 |
```rust
use regex_syntax::hir::{
self, ClassBytesRange, ClassUnicodeRange, Hir, HirKind,
};
use crate::error::{Error, ErrorKind};
/// Returns an error when a sub-expression in `expr` must match `byte`.
pub(crate) fn check(expr: &Hir, byte: u8) -> Result<(), Error> {
assert!(byte.is_ascii(), "ban byte must be ... | /content/code_sandbox/crates/regex/src/ban.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 702 |
```rust
use {
grep_matcher::LineTerminator,
regex_syntax::hir::{self, Hir, HirKind},
};
use crate::error::{Error, ErrorKind};
/// Return an HIR that is guaranteed to never match the given line terminator,
/// if possible.
///
/// If the transformation isn't possible, then an error is returned.
///
/// In gene... | /content/code_sandbox/crates/regex/src/strip.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,624 |
```rust
/*!
An implementation of `grep-matcher`'s `Matcher` trait for Rust's regex engine.
*/
#![deny(missing_docs)]
pub use crate::{
error::{Error, ErrorKind},
matcher::{RegexCaptures, RegexMatcher, RegexMatcherBuilder},
};
mod ast;
mod ban;
mod config;
mod error;
mod literal;
mod matcher;
mod non_matching;
... | /content/code_sandbox/crates/regex/src/lib.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 81 |
```rust
use regex_syntax::ast::{self, Ast};
/// The results of analyzing AST of a regular expression (e.g., for supporting
/// smart case).
#[derive(Clone, Debug)]
pub(crate) struct AstAnalysis {
/// True if and only if a literal uppercase character occurs in the regex.
any_uppercase: bool,
/// True if and... | /content/code_sandbox/crates/regex/src/ast.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,490 |
```rust
use {
grep_matcher::{ByteSet, LineTerminator},
regex_automata::meta::Regex,
regex_syntax::{
ast,
hir::{self, Hir},
},
};
use crate::{
ast::AstAnalysis, ban, error::Error, non_matching::non_matching_bytes,
strip::strip_from_match,
};
/// Config represents the configurati... | /content/code_sandbox/crates/regex/src/config.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 3,274 |
```rust
use {
grep_matcher::{
ByteSet, Captures, LineMatchKind, LineTerminator, Match, Matcher,
NoError,
},
regex_automata::{
meta::Regex, util::captures::Captures as AutomataCaptures, Input,
PatternID,
},
};
use crate::{config::Config, error::Error, literal::InnerLitera... | /content/code_sandbox/crates/regex/src/matcher.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 6,022 |
```rust
use {
regex_automata::meta::Regex,
regex_syntax::hir::{
self,
literal::{Literal, Seq},
Hir,
},
};
use crate::{config::ConfiguredHIR, error::Error};
/// A type that encapsulates "inner" literal extractiong from a regex.
///
/// It uses a huge pile of heuristics to try to plu... | /content/code_sandbox/crates/regex/src/literal.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 9,899 |
```rust
/*!
This module defines some macros and some light shared mutable state.
This state is responsible for keeping track of whether we should emit certain
kinds of messages to the user (such as errors) that are distinct from the
standard "debug" or "trace" log messages. This state is specifically set at
startup ti... | /content/code_sandbox/crates/core/messages.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,155 |
```rust
/*!
Defines a very high level "search worker" abstraction.
A search worker manages the high level interaction points between the matcher
(i.e., which regex engine is used), the searcher (i.e., how data is actually
read and matched using the regex engine) and the printer. For example, the
search worker is where... | /content/code_sandbox/crates/core/search.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 3,507 |
```rust
/*!
Defines a builder for haystacks.
A "haystack" represents something we want to search. It encapsulates the logic
for whether a haystack ought to be searched or not, separate from the standard
ignore rules and other filtering logic.
Effectively, a haystack wraps a directory entry and adds some light applica... | /content/code_sandbox/crates/core/haystack.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,318 |
```rust
/*!
Defines a super simple logger that works with the `log` crate.
We don't do anything fancy. We just need basic log levels and the ability to
print to stderr. We therefore avoid bringing in extra dependencies just for
this functionality.
*/
use log::Log;
/// The simplest possible logger that logs to stderr... | /content/code_sandbox/crates/core/logger.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 434 |
```rust
/*!
The main entry point into ripgrep.
*/
use std::{io::Write, process::ExitCode};
use ignore::WalkState;
use crate::flags::{HiArgs, SearchMode};
#[macro_use]
mod messages;
mod flags;
mod haystack;
mod logger;
mod search;
// Since Rust no longer uses jemalloc by default, ripgrep will, by default,
// use t... | /content/code_sandbox/crates/core/main.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,134 |
```rust
/*!
Parses command line arguments into a structured and typed representation.
*/
use std::{borrow::Cow, collections::BTreeSet, ffi::OsString};
use anyhow::Context;
use crate::flags::{
defs::FLAGS,
hiargs::HiArgs,
lowargs::{LoggingMode, LowArgs, SpecialMode},
Flag, FlagValue,
};
/// The resul... | /content/code_sandbox/crates/core/flags/parse.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,138 |
```rust
/*!
Defines ripgrep's command line interface.
This modules deals with everything involving ripgrep's flags and positional
arguments. This includes generating shell completions, `--help` output and even
ripgrep's man page. It's also responsible for parsing and validating every
flag (including reading ripgrep's ... | /content/code_sandbox/crates/core/flags/mod.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,671 |
```rust
/*!
This module provides routines for reading ripgrep config "rc" files.
The primary output of these routines is a sequence of arguments, where each
argument corresponds precisely to one shell argument.
*/
use std::{
ffi::OsString,
path::{Path, PathBuf},
};
use bstr::{io::BufReadExt, ByteSlice};
///... | /content/code_sandbox/crates/core/flags/config.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,157 |
```rust
/*!
Provides the definition of low level arguments from CLI flags.
*/
use std::{
ffi::{OsStr, OsString},
path::PathBuf,
};
use {
bstr::{BString, ByteVec},
grep::printer::{HyperlinkFormat, UserColorSpec},
};
/// A collection of "low level" arguments.
///
/// The "low level" here is meant to co... | /content/code_sandbox/crates/core/flags/lowargs.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 6,057 |
```rust
/*!
Provides the definition of high level arguments from CLI flags.
*/
use std::{
collections::HashSet,
path::{Path, PathBuf},
};
use {
bstr::BString,
grep::printer::{ColorSpecs, SummaryKind},
};
use crate::{
flags::lowargs::{
BinaryMode, BoundaryMode, BufferMode, CaseMode, ColorC... | /content/code_sandbox/crates/core/flags/hiargs.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 12,411 |
```rust
/*!
Provides completions for ripgrep's CLI for the bash shell.
*/
use crate::flags::defs::FLAGS;
const TEMPLATE_FULL: &'static str = "
_rg() {
local i cur prev opts cmds
COMPREPLY=()
cur=\"${COMP_WORDS[COMP_CWORD]}\"
prev=\"${COMP_WORDS[COMP_CWORD-1]}\"
cmd=\"\"
opts=\"\"
for i in ${COMP_WORDS[... | /content/code_sandbox/crates/core/flags/complete/bash.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 723 |
```rust
/*!
Modules for generating completions for various shells.
*/
static ENCODINGS: &'static str = include_str!("encodings.sh");
pub(super) mod bash;
pub(super) mod fish;
pub(super) mod powershell;
pub(super) mod zsh;
``` | /content/code_sandbox/crates/core/flags/complete/mod.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 54 |
```rust
/*!
Provides completions for ripgrep's CLI for the fish shell.
*/
use crate::flags::{defs::FLAGS, CompletionType};
const TEMPLATE: &'static str = "complete -c rg !SHORT! -l !LONG! -d '!DOC!'";
const TEMPLATE_NEGATED: &'static str =
"complete -c rg -l !NEGATED! -n '__fish_contains_opt !SHORT! !LONG!' -d '!... | /content/code_sandbox/crates/core/flags/complete/fish.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 517 |
```shell
#compdef rg
##
# zsh completion function for ripgrep
#
# Run ci/test-complete after building to ensure that the options supported by
# this function stay in synch with the `rg` binary.
#
# For convenience, a completion reference guide is included at the bottom of
# this file.
#
# Originally based on code from... | /content/code_sandbox/crates/core/flags/complete/rg.zsh | shell | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 7,347 |
```rust
/*!
Provides completions for ripgrep's CLI for the zsh shell.
Unlike completion short for other shells (at time of writing), zsh's
completions for ripgrep are maintained by hand. This is because:
1. They are lovingly written by an expert in such things.
2. Are much higher in quality than the ones below that a... | /content/code_sandbox/crates/core/flags/complete/zsh.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 222 |
```rust
/*!
Provides completions for ripgrep's CLI for PowerShell.
*/
use crate::flags::defs::FLAGS;
const TEMPLATE: &'static str = "
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'rg' -ScriptBlock {
param($wordToC... | /content/code_sandbox/crates/core/flags/complete/powershell.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 638 |
```shell
# This is impossible to read, but these encodings rarely if ever change, so
# it probably does not matter. They are derived from the list given here:
# path_to_url#concept-encoding-get
#
# The globbing here works in both fish and zsh (though they expand it in
# different orders). It may work in other shells to... | /content/code_sandbox/crates/core/flags/complete/encodings.sh | shell | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 711 |
```rust
/*!
Provides routines for generating version strings.
Version strings can be just the digits, an overall short one-line description
or something more verbose that includes things like CPU target feature support.
*/
use std::fmt::Write;
/// Generates just the numerical part of the version of ripgrep.
///
/// ... | /content/code_sandbox/crates/core/flags/doc/version.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,395 |
```rust
/*!
Modules for generating documentation for ripgrep's flags.
*/
pub(crate) mod help;
pub(crate) mod man;
pub(crate) mod version;
/// Searches for `\tag{...}` occurrences in `doc` and calls `replacement` for
/// each such tag found.
///
/// The first argument given to `replacement` is the tag value, `...`. Th... | /content/code_sandbox/crates/core/flags/doc/mod.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 308 |
```rust
/*!
Provides routines for generating ripgrep's "short" and "long" help
documentation.
The short version is used when the `-h` flag is given, while the long version
is used when the `--help` flag is given.
*/
use std::{collections::BTreeMap, fmt::Write};
use crate::flags::{defs::FLAGS, doc::version, Category,... | /content/code_sandbox/crates/core/flags/doc/help.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,333 |
```groff
.TH RG 1 2023-11-26 "!!VERSION!!" "User Commands"
.
.
.SH NAME
rg \- recursively search the current directory for lines matching a pattern
.
.
.SH SYNOPSIS
.\" I considered using GNU troff's .SY and .YS "synopsis" macros here, but it
.\" looks like they aren't portable. Specifically, they don't appear to be in... | /content/code_sandbox/crates/core/flags/doc/template.rg.1 | groff | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,024 |
```rust
/*!
Provides routines for generating ripgrep's man page in `roff` format.
*/
use std::{collections::BTreeMap, fmt::Write};
use crate::flags::{defs::FLAGS, doc::version, Flag};
const TEMPLATE: &'static str = include_str!("template.rg.1");
/// Wraps `std::write!` and asserts there is no failure.
///
/// We on... | /content/code_sandbox/crates/core/flags/doc/man.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 969 |
```rust
use std::path::Path;
use ignore::gitignore::{Gitignore, GitignoreBuilder};
const IGNORE_FILE: &'static str =
"tests/gitignore_matched_path_or_any_parents_tests.gitignore";
fn get_gitignore() -> Gitignore {
let mut builder = GitignoreBuilder::new("ROOT");
let error = builder.add(IGNORE_FILE);
... | /content/code_sandbox/crates/ignore/tests/gitignore_matched_path_or_any_parents_tests.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 3,641 |
```rust
/// This list represents the default file types that ripgrep ships with. In
/// general, any file format is fair game, although it should generally be
/// limited to reasonably popular open formats. For other cases, you can add
/// types to each invocation of ripgrep with the '--type-add' flag.
///
/// If you w... | /content/code_sandbox/crates/ignore/src/default_types.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,324 |
```rust
/*!
Defines all of the flags available in ripgrep.
Each flag corresponds to a unit struct with a corresponding implementation
of `Flag`. Note that each implementation of `Flag` might actually have many
possible manifestations of the same "flag." That is, each implementation of
`Flag` can have the following fla... | /content/code_sandbox/crates/core/flags/defs.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 60,138 |
```rust
use std::{ffi::OsStr, path::Path};
use crate::walk::DirEntry;
/// Returns true if and only if this entry is considered to be hidden.
///
/// This only returns true if the base name of the path starts with a `.`.
///
/// On Unix, this implements a more optimized check.
#[cfg(unix)]
pub(crate) fn is_hidden(dent... | /content/code_sandbox/crates/ignore/src/pathutil.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,260 |
```rust
/*!
The gitignore module provides a way to match globs from a gitignore file
against file paths.
Note that this module implements the specification as described in the
`gitignore` man page from scratch. That is, this module does *not* shell out to
the `git` command line tool.
*/
use std::{
fs::File,
i... | /content/code_sandbox/crates/ignore/src/gitignore.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 7,477 |
```rust
/*!
The ignore crate provides a fast recursive directory iterator that respects
various filters such as globs, file types and `.gitignore` files. The precise
matching rules and precedence is explained in the documentation for
`WalkBuilder`.
Secondarily, this crate exposes gitignore and file type matchers for u... | /content/code_sandbox/crates/ignore/src/lib.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,242 |
```rust
use std::{
cmp::Ordering,
ffi::OsStr,
fs::{self, FileType, Metadata},
io,
path::{Path, PathBuf},
sync::atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering},
sync::Arc,
};
use {
crossbeam_deque::{Stealer, Worker as Deque},
same_file::Handle,
walkdir::WalkDir,
};
... | /content/code_sandbox/crates/ignore/src/walk.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 18,052 |
```rust
/*!
The overrides module provides a way to specify a set of override globs.
This provides functionality similar to `--include` or `--exclude` in command
line tools.
*/
use std::path::Path;
use crate::{
gitignore::{self, Gitignore, GitignoreBuilder},
Error, Match,
};
/// Glob represents a single glob ... | /content/code_sandbox/crates/ignore/src/overrides.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,219 |
```rust
/*!
The types module provides a way of associating globs on file names to file
types.
This can be used to match specific types of files. For example, among
the default file types provided, the Rust file type is defined to be `*.rs`
with name `rust`. Similarly, the C file type is defined to be `*.{c,h}` with
na... | /content/code_sandbox/crates/ignore/src/types.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,582 |
```rust
use std::{env, io::Write, path::Path};
use {bstr::ByteVec, ignore::WalkBuilder, walkdir::WalkDir};
fn main() {
let mut path = env::args().nth(1).unwrap();
let mut parallel = false;
let mut simple = false;
let (tx, rx) = crossbeam_channel::bounded::<DirEntry>(100);
if path == "parallel" {
... | /content/code_sandbox/crates/ignore/examples/walk.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 436 |
```rust
/// An error that can occur in this crate.
///
/// Generally, this error corresponds to problems building a regular
/// expression, whether it's in parsing, compilation or a problem with
/// guaranteeing a configured optimization.
#[derive(Clone, Debug)]
pub struct Error {
kind: ErrorKind,
}
impl Error {
... | /content/code_sandbox/crates/pcre2/src/error.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 324 |
```rust
/*!
An implementation of `grep-matcher`'s `Matcher` trait for
[PCRE2](path_to_url
*/
#![deny(missing_docs)]
pub use pcre2::{is_jit_available, version};
pub use crate::{
error::{Error, ErrorKind},
matcher::{RegexCaptures, RegexMatcher, RegexMatcherBuilder},
};
mod error;
mod matcher;
``` | /content/code_sandbox/crates/pcre2/src/lib.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 80 |
```rust
// This module provides a data structure, `Ignore`, that connects "directory
// traversal" with "ignore matchers." Specifically, it knows about gitignore
// semantics and precedence, and is organized based on directory hierarchy.
// Namely, every matcher logically corresponds to ignore rules from a single
// di... | /content/code_sandbox/crates/ignore/src/dir.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 9,930 |
```rust
use std::collections::HashMap;
use {
grep_matcher::{Captures, Match, Matcher},
pcre2::bytes::{CaptureLocations, Regex, RegexBuilder},
};
use crate::error::Error;
/// A builder for configuring the compilation of a PCRE2 regex.
#[derive(Clone, Debug)]
pub struct RegexMatcherBuilder {
builder: Regex... | /content/code_sandbox/crates/pcre2/src/matcher.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,244 |
```rust
use std::{
io::{self, Write},
path::Path,
time::Instant,
};
use {
grep_matcher::{Match, Matcher},
grep_searcher::{
Searcher, Sink, SinkContext, SinkContextKind, SinkFinish, SinkMatch,
},
serde_json as json,
};
use crate::{
counter::CounterWriter, jsont, stats::Stats, ut... | /content/code_sandbox/crates/printer/src/json.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 8,732 |
```rust
/// Like assert_eq, but nicer output for long strings.
#[cfg(test)]
#[macro_export]
macro_rules! assert_eq_printed {
($expected:expr, $got:expr) => {
let expected = &*$expected;
let got = &*$got;
if expected != got {
panic!("
printed outputs differ!
expected:
~~~~~~~~~~~... | /content/code_sandbox/crates/printer/src/macros.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 110 |
```rust
use std::{
cell::RefCell,
io::{self, Write},
path::Path,
sync::Arc,
time::Instant,
};
use {
grep_matcher::Matcher,
grep_searcher::{Searcher, Sink, SinkError, SinkFinish, SinkMatch},
termcolor::{ColorSpec, NoColor, WriteColor},
};
use crate::{
color::ColorSpecs,
counter:... | /content/code_sandbox/crates/printer/src/summary.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 9,041 |
```rust
use std::{
ops::{Add, AddAssign},
time::Duration,
};
use crate::util::NiceDuration;
/// Summary statistics produced at the end of a search.
///
/// When statistics are reported by a printer, they correspond to all searches
/// executed with that printer.
#[derive(Clone, Debug, Default, PartialEq, Eq)]... | /content/code_sandbox/crates/printer/src/stats.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,164 |
```rust
/// Aliases to well-known hyperlink schemes.
///
/// These need to be sorted by name.
const HYPERLINK_PATTERN_ALIASES: &[(&str, &str)] = &[
#[cfg(not(windows))]
("default", "file://{host}{path}"),
#[cfg(windows)]
("default", "file://{path}"),
("file", "file://{host}{path}"),
// path_to_u... | /content/code_sandbox/crates/printer/src/hyperlink_aliases.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 749 |
```rust
use std::{io, path::Path};
use termcolor::WriteColor;
use crate::{
color::ColorSpecs,
hyperlink::{self, HyperlinkConfig},
util::PrinterPath,
};
/// A configuration for describing how paths should be written.
#[derive(Clone, Debug)]
struct Config {
colors: ColorSpecs,
hyperlink: HyperlinkC... | /content/code_sandbox/crates/printer/src/path.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,380 |
```rust
use termcolor::{Color, ColorSpec, ParseColorError};
/// Returns a default set of color specifications.
///
/// This may change over time, but the color choices are meant to be fairly
/// conservative that work across terminal themes.
///
/// Additional color specifications can be added to the list returned. Mo... | /content/code_sandbox/crates/printer/src/color.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,926 |
```rust
use std::{cell::RefCell, io, path::Path, sync::Arc};
use {
bstr::ByteSlice,
termcolor::{HyperlinkSpec, WriteColor},
};
use crate::{hyperlink_aliases, util::DecimalFormatter};
/// Hyperlink configuration.
///
/// This configuration specifies both the [hyperlink format](HyperlinkFormat)
/// and an [env... | /content/code_sandbox/crates/printer/src/hyperlink.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 7,869 |
```rust
/*!
This crate provides featureful and fast printers that interoperate with the
[`grep-searcher`](path_to_url
crate.
# Brief overview
The [`Standard`] printer shows results in a human readable format, and is
modeled after the formats used by standard grep-like tools. Features include,
but are not limited to, ... | /content/code_sandbox/crates/printer/src/lib.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 823 |
```rust
// This module defines the types we use for JSON serialization. We specifically
// omit deserialization, partially because there isn't a clear use case for
// them at this time, but also because deserialization will complicate things.
// Namely, the types below are designed in a way that permits JSON
// seriali... | /content/code_sandbox/crates/printer/src/jsont.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,568 |
```rust
use std::{borrow::Cow, cell::OnceCell, fmt, io, path::Path, time};
use {
bstr::ByteVec,
grep_matcher::{Captures, LineTerminator, Match, Matcher},
grep_searcher::{
LineIter, Searcher, SinkContext, SinkContextKind, SinkError, SinkMatch,
},
};
use crate::{hyperlink::HyperlinkPath, MAX_LOO... | /content/code_sandbox/crates/printer/src/util.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,875 |
```rust
use std::io::{self, Write};
use termcolor::{ColorSpec, HyperlinkSpec, WriteColor};
/// A writer that counts the number of bytes that have been successfully
/// written.
#[derive(Clone, Debug)]
pub(crate) struct CounterWriter<W> {
wtr: W,
count: u64,
total_count: u64,
}
impl<W: Write> CounterWrite... | /content/code_sandbox/crates/printer/src/counter.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 611 |
```rust
use std::borrow::Cow;
use bstr::{ByteSlice, ByteVec};
/// The final component of the path, if it is a normal file.
///
/// If the path terminates in `.`, `..`, or consists solely of a root of
/// prefix, file_name will return None.
pub(crate) fn file_name<'a>(path: &Cow<'a, [u8]>) -> Option<Cow<'a, [u8]>> {
... | /content/code_sandbox/crates/globset/src/pathutil.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,125 |
```rust
/*!
The globset crate provides cross platform single glob and glob set matching.
Glob set matching is the process of matching one or more glob patterns against
a single candidate path simultaneously, and returning all of the globs that
matched. For example, given this set of globs:
* `*.rs`
* `src/lib.rs`
* `... | /content/code_sandbox/crates/globset/src/lib.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 7,686 |
```rust
/// A convenience alias for creating a hash map with an FNV hasher.
pub(crate) type HashMap<K, V> =
std::collections::HashMap<K, V, std::hash::BuildHasherDefault<Hasher>>;
/// A hasher that implements the FowlerNollVo (FNV) hash.
pub(crate) struct Hasher(u64);
impl Hasher {
const OFFSET_BASIS: u64 = 0... | /content/code_sandbox/crates/globset/src/fnv.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 234 |
```rust
use serde::{
de::{Error, SeqAccess, Visitor},
{Deserialize, Deserializer, Serialize, Serializer},
};
use crate::{Glob, GlobSet, GlobSetBuilder};
impl Serialize for Glob {
fn serialize<S: Serializer>(
&self,
serializer: S,
) -> Result<S::Ok, S::Error> {
serializer.serial... | /content/code_sandbox/crates/globset/src/serde_impl.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 828 |
```rust
use std::{
cell::{Cell, RefCell},
cmp,
io::{self, Write},
path::Path,
sync::Arc,
time::Instant,
};
use {
bstr::ByteSlice,
grep_matcher::{Match, Matcher},
grep_searcher::{
LineStep, Searcher, Sink, SinkContext, SinkContextKind, SinkFinish,
SinkMatch,
},
... | /content/code_sandbox/crates/printer/src/standard.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 29,540 |
```rust
/*!
This module benchmarks the glob implementation. For benchmarks on the ripgrep
tool itself, see the benchsuite directory.
*/
#![feature(test)]
extern crate test;
use globset::{Candidate, Glob, GlobMatcher, GlobSet, GlobSetBuilder};
const EXT: &'static str = "some/a/bigger/path/to/the/crazy/needle.txt";
co... | /content/code_sandbox/crates/globset/benches/bench.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 792 |
```rust
use std::fmt::Write;
use std::path::{is_separator, Path};
use regex_automata::meta::Regex;
use crate::{new_regex, Candidate, Error, ErrorKind};
/// Describes a matching strategy for a particular pattern.
///
/// This provides a way to more quickly determine whether a pattern matches
/// a particular file pat... | /content/code_sandbox/crates/globset/src/glob.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 14,012 |
```rust
/// Like assert_eq, but nicer output for long strings.
#[cfg(test)]
#[macro_export]
macro_rules! assert_eq_printed {
($expected:expr, $got:expr, $($tt:tt)*) => {
let expected = &*$expected;
let got = &*$got;
let label = format!($($tt)*);
if expected != got {
panic... | /content/code_sandbox/crates/searcher/src/macros.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 134 |
```rust
use std::io::{self, Write};
use {
bstr::ByteSlice,
grep_matcher::{
LineMatchKind, LineTerminator, Match, Matcher, NoCaptures, NoError,
},
regex::bytes::{Regex, RegexBuilder},
};
use crate::{
searcher::{BinaryDetection, Searcher, SearcherBuilder},
sink::{Sink, SinkContext, SinkF... | /content/code_sandbox/crates/searcher/src/testutil.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 6,006 |
```rust
/*!
A collection of routines for performing operations on lines.
*/
use {
bstr::ByteSlice,
grep_matcher::{LineTerminator, Match},
};
/// An iterator over lines in a particular slice of bytes.
///
/// Line terminators are considered part of the line they terminate. All lines
/// yielded by the iterator... | /content/code_sandbox/crates/searcher/src/lines.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,939 |
```rust
use std::io;
use grep_matcher::LineTerminator;
use crate::{
lines::LineIter,
searcher::{ConfigError, Searcher},
};
/// A trait that describes errors that can be reported by searchers and
/// implementations of `Sink`.
///
/// Unless you have a specialized use case, you probably don't need to
/// impl... | /content/code_sandbox/crates/searcher/src/sink.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 5,511 |
```rust
/*!
This crate provides an implementation of line oriented search, with optional
support for multi-line search.
# Brief overview
The principle type in this crate is a [`Searcher`], which can be configured
and built by a [`SearcherBuilder`]. A `Searcher` is responsible for reading
bytes from a source (e.g., a ... | /content/code_sandbox/crates/searcher/src/lib.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 883 |
```rust
use bstr::ByteSlice;
use grep_matcher::{LineMatchKind, Matcher};
use crate::{
line_buffer::BinaryDetection,
lines::{self, LineStep},
searcher::{Config, Range, Searcher},
sink::{
Sink, SinkContext, SinkContextKind, SinkError, SinkFinish, SinkMatch,
},
};
enum FastMatchResult {
... | /content/code_sandbox/crates/searcher/src/searcher/core.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,472 |
```rust
use std::io;
use bstr::ByteSlice;
/// The default buffer capacity that we use for the line buffer.
pub(crate) const DEFAULT_BUFFER_CAPACITY: usize = 64 * (1 << 10); // 64 KB
/// The behavior of a searcher in the face of long lines and big contexts.
///
/// When searching data incrementally using a fixed size... | /content/code_sandbox/crates/searcher/src/line_buffer.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 8,232 |
```rust
use std::{fs::File, path::Path};
use memmap::Mmap;
/// Controls the strategy used for determining when to use memory maps.
///
/// If a searcher is called in circumstances where it is possible to use memory
/// maps, and memory maps are enabled, then it will attempt to do so if it
/// believes it will make th... | /content/code_sandbox/crates/searcher/src/searcher/mmap.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 833 |
```rust
use std::{
cell::RefCell,
cmp,
fs::File,
io::{self, Read},
path::Path,
};
use {
encoding_rs_io::DecodeReaderBytesBuilder,
grep_matcher::{LineTerminator, Match, Matcher},
};
use crate::{
line_buffer::{
self, alloc_error, BufferAllocation, LineBuffer, LineBufferBuilder,
... | /content/code_sandbox/crates/searcher/src/searcher/mod.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 8,915 |
```rust
use std::env;
use std::error::Error;
use std::io;
use std::process;
use grep_regex::RegexMatcher;
use grep_searcher::sinks::UTF8;
use grep_searcher::Searcher;
fn main() {
if let Err(err) = example() {
eprintln!("{}", err);
process::exit(1);
}
}
fn example() -> Result<(), Box<dyn Error... | /content/code_sandbox/crates/searcher/examples/search-stdin.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 200 |
```rust
use std::{ffi::OsString, io};
/// Returns the hostname of the current system.
///
/// It is unusual, although technically possible, for this routine to return
/// an error. It is difficult to list out the error conditions, but one such
/// possibility is platform support.
///
/// # Platform specific behavior
/... | /content/code_sandbox/crates/cli/src/hostname.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 758 |
```rust
use std::{
ffi::{OsStr, OsString},
fs::File,
io,
path::{Path, PathBuf},
process::Command,
};
use globset::{Glob, GlobSet, GlobSetBuilder};
use crate::process::{CommandError, CommandReader, CommandReaderBuilder};
/// A builder for a matcher that determines which files get decompressed.
#[d... | /content/code_sandbox/crates/cli/src/decompress.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 4,686 |
```rust
/// An error that occurs when parsing a human readable size description.
///
/// This error provides an end user friendly message describing why the
/// description couldn't be parsed and what the expected format is.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ParseSizeError {
original: String,
ki... | /content/code_sandbox/crates/cli/src/human.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,038 |
```rust
use grep_matcher::Matcher;
use crate::{
line_buffer::{LineBufferReader, DEFAULT_BUFFER_CAPACITY},
lines::{self, LineStep},
searcher::{core::Core, Config, Range, Searcher},
sink::{Sink, SinkError},
};
#[derive(Debug)]
pub(crate) struct ReadByLine<'s, M, R, S> {
config: &'s Config,
core:... | /content/code_sandbox/crates/searcher/src/searcher/glue.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 12,130 |
```rust
use std::{
io::{self, Read},
process,
};
/// An error that can occur while running a command and reading its output.
///
/// This error can be seamlessly converted to an `io::Error` via a `From`
/// implementation.
#[derive(Debug)]
pub struct CommandError {
kind: CommandErrorKind,
}
#[derive(Debug... | /content/code_sandbox/crates/cli/src/process.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,511 |
```rust
/*!
This crate provides common routines used in command line applications, with a
focus on routines useful for search oriented applications. As a utility
library, there is no central type or function. However, a key focus of this
crate is to improve failure modes and provide user friendly error messages
when th... | /content/code_sandbox/crates/cli/src/lib.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 2,577 |
```rust
use std::io::{self, IsTerminal};
use termcolor::HyperlinkSpec;
/// A writer that supports coloring with either line or block buffering.
#[derive(Debug)]
pub struct StandardStream(StandardStreamKind);
/// Returns a possibly buffered writer to stdout for the given color choice.
///
/// The writer returned is e... | /content/code_sandbox/crates/cli/src/wtr.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,112 |
```rust
use std::ffi::OsStr;
use bstr::{ByteSlice, ByteVec};
/// Escapes arbitrary bytes into a human readable string.
///
/// This converts `\t`, `\r` and `\n` into their escaped forms. It also
/// converts the non-printable subset of ASCII in addition to invalid UTF-8
/// bytes to hexadecimal escape sequences. Ever... | /content/code_sandbox/crates/cli/src/escape.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,219 |
```rust
use std::{ffi::OsStr, io, path::Path};
use bstr::io::BufReadExt;
use crate::escape::{escape, escape_os};
/// An error that occurs when a pattern could not be converted to valid UTF-8.
///
/// The purpose of this error is to give a more targeted failure mode for
/// patterns written by end users that are not ... | /content/code_sandbox/crates/cli/src/pattern.rs | rust | 2016-03-11T02:02:33 | 2024-08-16T17:03:13 | ripgrep | BurntSushi/ripgrep | 47,035 | 1,415 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.