Skip to content

Commit

Permalink
Merge branch 'main' into p-quote_filenames
Browse files Browse the repository at this point in the history
Signed-off-by: Preston Thorpe <preston@unlockedlabs.org>
  • Loading branch information
PThorpe92 authored Sep 24, 2023
2 parents c7df611 + 7f70c2a commit 4496892
Show file tree
Hide file tree
Showing 72 changed files with 2,475 additions and 1,854 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ jobs:
max_attempts: 5
command: cargo install cargo-hack

- name: Run unit tests
run: cargo hack test
- name: Run rustfmt checks
run: cargo fmt --check

- name: Run clippy lints
run: cargo clippy -- -D warnings

- name: Run unit tests
run: cargo hack test
1 change: 0 additions & 1 deletion .rustfmt.toml

This file was deleted.

43 changes: 6 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ percent-encoding = "2.3.0"
phf = { version = "0.11.2", features = ["macros"] }
scoped_threadpool = "0.1"
term_grid = "0.1"
terminal_size = "0.2.6"
terminal_size = "0.3.0"
timeago = { version = "0.4.2", default-features = false }
unicode-width = "0.1"
zoneinfo_compiled = "0.5.1"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ eza’s options are almost, but not quite, entirely unlike `ls`’s.
- **-s**, **--sort=(field)**: which field to sort by
- **--group-directories-first**: list directories before other files
- **-D**, **--only-dirs**: list only directories
- **-f**, **--only-files**: list only files
- **--git-ignore**: ignore files mentioned in `.gitignore`
- **-I**, **--ignore-glob=(globs)**: glob patterns (pipe-separated) of files to ignore

Expand Down
6 changes: 5 additions & 1 deletion benches/my_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};

pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("logger", |b| b.iter(|| eza::logger::configure(black_box(std::env::var_os(eza::options::vars::EZA_DEBUG)))));
c.bench_function("logger", |b| {
b.iter(|| {
eza::logger::configure(black_box(std::env::var_os(eza::options::vars::EZA_DEBUG)))
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
60 changes: 36 additions & 24 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,58 @@
///
/// - https://stackoverflow.com/q/43753491/3484614
/// - https://crates.io/crates/vergen

use std::env;
use std::fs::File;
use std::io::{self, Write};
use std::path::PathBuf;

use chrono::prelude::*;


/// The build script entry point.
fn main() -> io::Result<()> {
#![allow(clippy::write_with_newline)]

let tagline = "eza - A modern, maintained replacement for ls";
let url = "https://github.com/eza-community/eza";

let ver =
if is_debug_build() {
format!("{}\nv{} \\1;31m(pre-release debug build!)\\0m\n\\1;4;34m{}\\0m", tagline, version_string(), url)
}
else if is_development_version() {
format!("{}\nv{} [{}] built on {} \\1;31m(pre-release!)\\0m\n\\1;4;34m{}\\0m", tagline, version_string(), git_hash(), build_date(), url)
}
else {
format!("{}\nv{}\n\\1;4;34m{}\\0m", tagline, version_string(), url)
};
let url = "https://github.com/eza-community/eza";

let ver = if is_debug_build() {
format!(
"{}\nv{} \\1;31m(pre-release debug build!)\\0m\n\\1;4;34m{}\\0m",
tagline,
version_string(),
url
)
} else if is_development_version() {
format!(
"{}\nv{} [{}] built on {} \\1;31m(pre-release!)\\0m\n\\1;4;34m{}\\0m",
tagline,
version_string(),
git_hash(),
build_date(),
url
)
} else {
format!("{}\nv{}\n\\1;4;34m{}\\0m", tagline, version_string(), url)
};

// We need to create these files in the Cargo output directory.
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
let path = &out.join("version_string.txt");

// Bland version text
let mut f = File::create(path).unwrap_or_else(|_| { panic!("{}", path.to_string_lossy().to_string()) });
let mut f =
File::create(path).unwrap_or_else(|_| panic!("{}", path.to_string_lossy().to_string()));
writeln!(f, "{}", strip_codes(&ver))?;

Ok(())
}

/// Removes escape codes from a string.
fn strip_codes(input: &str) -> String {
input.replace("\\0m", "")
.replace("\\1;31m", "")
.replace("\\1;4;34m", "")
input
.replace("\\0m", "")
.replace("\\1;31m", "")
.replace("\\1;4;34m", "")
}

/// Retrieve the project’s current Git hash, as a string.
Expand All @@ -61,8 +70,12 @@ fn git_hash() -> String {
String::from_utf8_lossy(
&Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output().unwrap()
.stdout).trim().to_string()
.output()
.unwrap()
.stdout,
)
.trim()
.to_string()
}

/// Whether we should show pre-release info in the version string.
Expand All @@ -88,7 +101,7 @@ fn version_string() -> String {
let mut ver = cargo_version();

let feats = nonstandard_features_string();
if ! feats.is_empty() {
if !feats.is_empty() {
ver.push_str(&format!(" [{}]", &feats));
}

Expand All @@ -98,7 +111,7 @@ fn version_string() -> String {
/// Finds whether a feature is enabled by examining the Cargo variable.
fn feature_enabled(name: &str) -> bool {
env::var(format!("CARGO_FEATURE_{}", name))
.map(|e| ! e.is_empty())
.map(|e| !e.is_empty())
.unwrap_or(false)
}

Expand All @@ -108,8 +121,7 @@ fn nonstandard_features_string() -> String {

if feature_enabled("GIT") {
s.push("+git");
}
else {
} else {
s.push("-git");
}

Expand Down
1 change: 1 addition & 0 deletions completions/fish/eza.fish
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ complete -c eza -s s -l sort -d "Which field to sort by" -x -a "

complete -c eza -s I -l ignore-glob -d "Ignore files that match these glob patterns" -r
complete -c eza -s D -l only-dirs -d "List only directories"
complete -c eza -s f -l only-files -d "List only files"

# Long view options
complete -c eza -s b -l binary -d "List file sizes with binary prefixes"
Expand Down
1 change: 1 addition & 0 deletions completions/zsh/_eza
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ __eza() {
{-a,--all}"[Show hidden and 'dot' files. Use this twice to also show the '.' and '..' directories]" \
{-d,--list-dirs}"[List directories like regular files]" \
{-D,--only-dirs}"[List only directories]" \
{-f,--only-files}"[List only files]" \
{-L,--level}"+[Limit the depth of recursion]" \
{-w,--width}"+[Limits column output of grid, 0 implies auto-width]" \
{-r,--reverse}"[Reverse the sort order]" \
Expand Down
3 changes: 3 additions & 0 deletions man/eza.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ Sort fields starting with a capital letter will sort uppercase before lowercase:
`-D`, `--only-dirs`
: List only directories, not files.

`-f`, `--only-files`
: List only files, not directories.


LONG VIEW OPTIONS
=================
Expand Down
Loading

0 comments on commit 4496892

Please sign in to comment.