mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
Turning oof
subcrate into a module
This commit is contained in:
parent
5a2028b117
commit
57a3d231eb
@ -21,9 +21,6 @@ tar = "0.4.33"
|
|||||||
xz2 = "0.1.6"
|
xz2 = "0.1.6"
|
||||||
zip = "0.5.11"
|
zip = "0.5.11"
|
||||||
|
|
||||||
# Dependency from workspace
|
|
||||||
oof = { path = "./oof" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3.7"
|
tempdir = "0.3.7"
|
||||||
rand = { version = "0.8.3", default-features = false, features = ["small_rng", "std"] }
|
rand = { version = "0.8.3", default-features = false, features = ["small_rng", "std"] }
|
||||||
@ -32,9 +29,3 @@ rand = { version = "0.8.3", default-features = false, features = ["small_rng", "
|
|||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
[workspace]
|
|
||||||
members = [
|
|
||||||
".",
|
|
||||||
"oof",
|
|
||||||
]
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "oof"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["João M. Bezerra <marcospb19@hotmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
description = "Ouch's argparsing library"
|
|
||||||
repository = "https://github.com/vrmiguel/ouch"
|
|
||||||
|
|
||||||
[dependencies]
|
|
@ -5,9 +5,10 @@ use std::{
|
|||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
|
||||||
use oof::{arg_flag, flag};
|
|
||||||
use strsim::normalized_damerau_levenshtein;
|
use strsim::normalized_damerau_levenshtein;
|
||||||
|
|
||||||
|
use crate::{arg_flag, flag, oof};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
/// Files to be compressed
|
/// Files to be compressed
|
||||||
|
@ -19,7 +19,7 @@ use crate::{
|
|||||||
dialogs::Confirmation,
|
dialogs::Confirmation,
|
||||||
extension::{CompressionFormat, Extension},
|
extension::{CompressionFormat, Extension},
|
||||||
file::File,
|
file::File,
|
||||||
utils,
|
oof, utils,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn run(command: Command, flags: &oof::Flags) -> crate::Result<()> {
|
pub fn run(command: Command, flags: &oof::Flags) -> crate::Result<()> {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::file::File;
|
use crate::{file::File, oof};
|
||||||
|
|
||||||
pub enum DecompressionResult {
|
pub enum DecompressionResult {
|
||||||
FilesUnpacked(Vec<PathBuf>),
|
FilesUnpacked(Vec<PathBuf>),
|
||||||
|
@ -8,7 +8,7 @@ use tar::{self, Archive};
|
|||||||
use utils::colors;
|
use utils::colors;
|
||||||
|
|
||||||
use super::decompressor::{DecompressionResult, Decompressor};
|
use super::decompressor::{DecompressionResult, Decompressor};
|
||||||
use crate::{dialogs::Confirmation, file::File, utils};
|
use crate::{dialogs::Confirmation, file::File, oof, utils};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TarDecompressor;
|
pub struct TarDecompressor;
|
||||||
|
@ -6,7 +6,7 @@ use std::{
|
|||||||
use utils::colors;
|
use utils::colors;
|
||||||
|
|
||||||
use super::decompressor::{DecompressionResult, Decompressor};
|
use super::decompressor::{DecompressionResult, Decompressor};
|
||||||
use crate::{extension::CompressionFormat, file::File, utils};
|
use crate::{extension::CompressionFormat, file::File, oof, utils};
|
||||||
|
|
||||||
struct DecompressorToMemory;
|
struct DecompressorToMemory;
|
||||||
pub struct GzipDecompressor;
|
pub struct GzipDecompressor;
|
||||||
|
@ -8,7 +8,7 @@ use utils::colors;
|
|||||||
use zip::{self, read::ZipFile, ZipArchive};
|
use zip::{self, read::ZipFile, ZipArchive};
|
||||||
|
|
||||||
use super::decompressor::{DecompressionResult, Decompressor};
|
use super::decompressor::{DecompressionResult, Decompressor};
|
||||||
use crate::{dialogs::Confirmation, file::File, utils};
|
use crate::{dialogs::Confirmation, file::File, oof, utils};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn __unix_set_permissions(file_path: &Path, file: &ZipFile) {
|
fn __unix_set_permissions(file_path: &Path, file: &ZipFile) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{fmt, path::PathBuf};
|
use std::{fmt, path::PathBuf};
|
||||||
|
|
||||||
use crate::utils::colors;
|
use crate::{oof, utils::colors};
|
||||||
|
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
UnknownExtensionError(String),
|
UnknownExtensionError(String),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Public modules
|
// Public modules
|
||||||
pub mod cli;
|
pub mod cli;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
|
pub mod oof;
|
||||||
|
|
||||||
// Private modules
|
// Private modules
|
||||||
mod compressors;
|
mod compressors;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{error, ffi::OsString, fmt};
|
use std::{error, ffi::OsString, fmt};
|
||||||
|
|
||||||
use crate::Flag;
|
use super::Flag;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum OofError {
|
pub enum OofError {
|
@ -217,7 +217,7 @@ where
|
|||||||
mod tests {
|
mod tests {
|
||||||
use std::os::unix::prelude::OsStringExt;
|
use std::os::unix::prelude::OsStringExt;
|
||||||
|
|
||||||
use crate::*;
|
use super::*;
|
||||||
|
|
||||||
fn gen_args(text: &str) -> Vec<OsString> {
|
fn gen_args(text: &str) -> Vec<OsString> {
|
||||||
let args = text.split_whitespace();
|
let args = text.split_whitespace();
|
@ -5,7 +5,7 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{dialogs::Confirmation, extension::CompressionFormat, file::File};
|
use crate::{dialogs::Confirmation, extension::CompressionFormat, file::File, oof};
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
@ -4,7 +4,7 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use ouch::{cli::Command, commands::run};
|
use ouch::{cli::Command, commands::run, oof};
|
||||||
use rand::{rngs::SmallRng, RngCore, SeedableRng};
|
use rand::{rngs::SmallRng, RngCore, SeedableRng};
|
||||||
use tempdir::TempDir;
|
use tempdir::TempDir;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user