mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
base64: use UResult
This commit is contained in:
parent
051284de4c
commit
452329ad19
1 changed files with 7 additions and 14 deletions
|
@ -12,7 +12,7 @@ extern crate uucore;
|
||||||
use uu_base32::base_common;
|
use uu_base32::base_common;
|
||||||
pub use uu_base32::uu_app;
|
pub use uu_base32::uu_app;
|
||||||
|
|
||||||
use uucore::encoding::Format;
|
use uucore::{encoding::Format, error::UResult};
|
||||||
|
|
||||||
use std::io::{stdin, Read};
|
use std::io::{stdin, Read};
|
||||||
|
|
||||||
|
@ -25,26 +25,22 @@ static ABOUT: &str = "
|
||||||
to attempt to recover from any other non-alphabet bytes in the
|
to attempt to recover from any other non-alphabet bytes in the
|
||||||
encoded stream.
|
encoded stream.
|
||||||
";
|
";
|
||||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
||||||
|
|
||||||
static BASE_CMD_PARSE_ERROR: i32 = 1;
|
|
||||||
|
|
||||||
fn usage() -> String {
|
fn usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
|
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
#[uucore_procs::gen_uumain]
|
||||||
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let format = Format::Base64;
|
let format = Format::Base64;
|
||||||
let usage = usage();
|
let usage = usage();
|
||||||
let name = uucore::util_name();
|
|
||||||
let config_result: Result<base_common::Config, String> =
|
let config: base_common::Config = base_common::parse_base_cmd_args(args, ABOUT, &usage)?;
|
||||||
base_common::parse_base_cmd_args(args, name, VERSION, ABOUT, &usage);
|
|
||||||
let config = config_result.unwrap_or_else(|s| crash!(BASE_CMD_PARSE_ERROR, "{}", s));
|
|
||||||
|
|
||||||
// Create a reference to stdin so we can return a locked stdin from
|
// Create a reference to stdin so we can return a locked stdin from
|
||||||
// parse_base_cmd_args
|
// parse_base_cmd_args
|
||||||
let stdin_raw = stdin();
|
let stdin_raw = stdin();
|
||||||
let mut input: Box<dyn Read> = base_common::get_input(&config, &stdin_raw);
|
let mut input: Box<dyn Read> = base_common::get_input(&config, &stdin_raw)?;
|
||||||
|
|
||||||
base_common::handle_input(
|
base_common::handle_input(
|
||||||
&mut input,
|
&mut input,
|
||||||
|
@ -52,8 +48,5 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
config.wrap_cols,
|
config.wrap_cols,
|
||||||
config.ignore_garbage,
|
config.ignore_garbage,
|
||||||
config.decode,
|
config.decode,
|
||||||
name,
|
)
|
||||||
);
|
|
||||||
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue