Skip to content

Commit

Permalink
Merge pull request #6719 from andrewliebenow/basenc-faster-encoding
Browse files Browse the repository at this point in the history
basenc: perform faster, streaming encoding
  • Loading branch information
sylvestre authored Oct 5, 2024
2 parents 50f9958 + 32e1c54 commit d41d51a
Show file tree
Hide file tree
Showing 15 changed files with 1,597 additions and 277 deletions.
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

0 comments on commit d41d51a

Please sign in to comment.