mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
Merge pull request #144 from ouch-org/updating-rustfmt
Updating rustfmt configurations
This commit is contained in:
commit
41a9734d3a
4
build.rs
4
build.rs
@ -1,8 +1,8 @@
|
|||||||
|
use std::{env, fs::create_dir_all, path::Path};
|
||||||
|
|
||||||
use clap::{ArgEnum, IntoApp};
|
use clap::{ArgEnum, IntoApp};
|
||||||
use clap_generate::{generate_to, Shell};
|
use clap_generate::{generate_to, Shell};
|
||||||
|
|
||||||
use std::{env, fs::create_dir_all, path::Path};
|
|
||||||
|
|
||||||
include!("src/opts.rs");
|
include!("src/opts.rs");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# Stable features
|
||||||
max_width = 120
|
max_width = 120
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
newline_style = "Unix"
|
newline_style = "Unix"
|
||||||
@ -6,5 +7,9 @@ reorder_imports = true
|
|||||||
reorder_modules = true
|
reorder_modules = true
|
||||||
use_try_shorthand = true
|
use_try_shorthand = true
|
||||||
use_small_heuristics = "Max"
|
use_small_heuristics = "Max"
|
||||||
|
|
||||||
|
# Unstable features (nightly only)
|
||||||
unstable_features = true
|
unstable_features = true
|
||||||
force_multiline_blocks = true
|
force_multiline_blocks = true
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
@ -7,10 +7,10 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use zip::{self, read::ZipFile, ZipArchive};
|
use zip::{self, read::ZipFile, ZipArchive};
|
||||||
|
|
||||||
|
use self::utf8::get_invalid_utf8_paths;
|
||||||
use crate::{
|
use crate::{
|
||||||
info,
|
info,
|
||||||
list::FileInArchive,
|
list::FileInArchive,
|
||||||
@ -18,8 +18,6 @@ use crate::{
|
|||||||
QuestionPolicy,
|
QuestionPolicy,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::utf8::get_invalid_utf8_paths;
|
|
||||||
|
|
||||||
/// Unpacks the archive given by `archive` into the folder given by `into`.
|
/// Unpacks the archive given by `archive` into the folder given by `into`.
|
||||||
pub fn unpack_archive<R>(
|
pub fn unpack_archive<R>(
|
||||||
mut archive: ZipArchive<R>,
|
mut archive: ZipArchive<R>,
|
||||||
@ -158,8 +156,7 @@ fn check_for_comments(file: &ZipFile) {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn __unix_set_permissions(file_path: &Path, file: &ZipFile) -> crate::Result<()> {
|
fn __unix_set_permissions(file_path: &Path, file: &ZipFile) -> crate::Result<()> {
|
||||||
use std::fs::Permissions;
|
use std::{fs::Permissions, os::unix::fs::PermissionsExt};
|
||||||
use std::os::unix::fs::PermissionsExt;
|
|
||||||
|
|
||||||
if let Some(mode) = file.unix_mode() {
|
if let Some(mode) = file.unix_mode() {
|
||||||
fs::set_permissions(file_path, Permissions::from_mode(mode))?;
|
fs::set_permissions(file_path, Permissions::from_mode(mode))?;
|
||||||
@ -175,8 +172,7 @@ mod utf8 {
|
|||||||
// Sad double reference in order to make `filter` happy in `get_invalid_utf8_paths`
|
// Sad double reference in order to make `filter` happy in `get_invalid_utf8_paths`
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn is_invalid_utf8(path: &&Path) -> bool {
|
fn is_invalid_utf8(path: &&Path) -> bool {
|
||||||
use std::os::unix::prelude::OsStrExt;
|
use std::{os::unix::prelude::OsStrExt, str};
|
||||||
use std::str;
|
|
||||||
|
|
||||||
// str::from_utf8 does not make any allocations
|
// str::from_utf8 does not make any allocations
|
||||||
let bytes = path.as_os_str().as_bytes();
|
let bytes = path.as_os_str().as_bytes();
|
||||||
|
11
src/list.rs
11
src/list.rs
@ -1,8 +1,9 @@
|
|||||||
//! Implementation of the 'list' command, print list of files in an archive
|
//! Implementation of the 'list' command, print list of files in an archive
|
||||||
|
|
||||||
use self::tree::Tree;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use self::tree::Tree;
|
||||||
|
|
||||||
/// Options controlling how archive contents should be listed
|
/// Options controlling how archive contents should be listed
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct ListOptions {
|
pub struct ListOptions {
|
||||||
@ -56,11 +57,11 @@ fn print_entry(name: impl std::fmt::Display, is_dir: bool) {
|
|||||||
/// we have to construct the tree structure ourselves to be able to
|
/// we have to construct the tree structure ourselves to be able to
|
||||||
/// display them as a tree
|
/// display them as a tree
|
||||||
mod tree {
|
mod tree {
|
||||||
use super::FileInArchive;
|
use std::{ffi::OsString, iter::FromIterator, path};
|
||||||
|
|
||||||
use linked_hash_map::LinkedHashMap;
|
use linked_hash_map::LinkedHashMap;
|
||||||
use std::ffi::OsString;
|
|
||||||
use std::iter::FromIterator;
|
use super::FileInArchive;
|
||||||
use std::path;
|
|
||||||
|
|
||||||
/// Directory tree
|
/// Directory tree
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use clap::{Parser, ValueHint};
|
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use clap::{Parser, ValueHint};
|
||||||
|
|
||||||
/// Command line options
|
/// Command line options
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(version, about)]
|
#[clap(version, about)]
|
||||||
|
@ -4,8 +4,7 @@ use std::{
|
|||||||
cmp, env,
|
cmp, env,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
io,
|
io,
|
||||||
path::Component,
|
path::{Component, Path, PathBuf},
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
|
@ -7,9 +7,8 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use ouch::{commands::run, Opts, QuestionPolicy, Subcommand};
|
|
||||||
|
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
|
use ouch::{commands::run, Opts, QuestionPolicy, Subcommand};
|
||||||
use rand::{rngs::SmallRng, RngCore, SeedableRng};
|
use rand::{rngs::SmallRng, RngCore, SeedableRng};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use utils::*;
|
use utils::*;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
|
|
||||||
use ouch::{commands::run, Opts, QuestionPolicy, Subcommand};
|
use ouch::{commands::run, Opts, QuestionPolicy, Subcommand};
|
||||||
|
|
||||||
pub fn create_empty_dir(at: &Path, filename: &str) -> PathBuf {
|
pub fn create_empty_dir(at: &Path, filename: &str) -> PathBuf {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user