Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basenc: perform faster, streaming encoding #6719

Merged
merged 17 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 81 additions & 23 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions src/uu/base32/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# spell-checker:ignore proptest

[package]
name = "uu_base32"
version = "0.0.27"
Expand All @@ -20,6 +22,9 @@ path = "src/base32.rs"
clap = { workspace = true }
uucore = { workspace = true, features = ["encoding"] }

[dev-dependencies]
proptest = "1.5.0"

[[bin]]
name = "base32"
path = "src/main.rs"
19 changes: 4 additions & 15 deletions src/uu/base32/src/base32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,23 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use std::io::{stdin, Read};
pub mod base_common;

use clap::Command;
use uucore::{encoding::Format, error::UResult, help_about, help_usage};

pub mod base_common;

const ABOUT: &str = help_about!("base32.md");
const USAGE: &str = help_usage!("base32.md");

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let format = Format::Base32;

let config: base_common::Config = base_common::parse_base_cmd_args(args, ABOUT, USAGE)?;
let config = base_common::parse_base_cmd_args(args, ABOUT, USAGE)?;

// Create a reference to stdin so we can return a locked stdin from
// parse_base_cmd_args
let stdin_raw = stdin();
let mut input: Box<dyn Read> = base_common::get_input(&config, &stdin_raw)?;
let mut input = base_common::get_input(&config)?;

base_common::handle_input(
&mut input,
format,
config.wrap_cols,
config.ignore_garbage,
config.decode,
)
base_common::handle_input(&mut input, format, config)
}

pub fn uu_app() -> Command {
Expand Down
Loading
Loading