mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
logname: replace getopts with clap
This commit is contained in:
parent
cdd3998a44
commit
b24b9d501b
3 changed files with 10 additions and 8 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2068,6 +2068,7 @@ dependencies = [
|
||||||
name = "uu_logname"
|
name = "uu_logname"
|
||||||
version = "0.0.6"
|
version = "0.0.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"clap",
|
||||||
"libc",
|
"libc",
|
||||||
"uucore",
|
"uucore",
|
||||||
"uucore_procs",
|
"uucore_procs",
|
||||||
|
|
|
@ -16,6 +16,7 @@ path = "src/logname.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
|
clap = "2.33"
|
||||||
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }
|
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }
|
||||||
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use uucore::InvalidEncodingHandling;
|
|
||||||
|
use clap::App;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// POSIX requires using getlogin (or equivalent code)
|
// POSIX requires using getlogin (or equivalent code)
|
||||||
|
@ -31,15 +32,14 @@ fn get_userlogin() -> Option<String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SYNTAX: &str = "";
|
|
||||||
static SUMMARY: &str = "Print user's login name";
|
static SUMMARY: &str = "Print user's login name";
|
||||||
static LONG_HELP: &str = "";
|
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(_: impl uucore::Args) -> i32 {
|
||||||
app!(SYNTAX, SUMMARY, LONG_HELP).parse(
|
let _ = App::new(executable!())
|
||||||
args.collect_str(InvalidEncodingHandling::ConvertLossy)
|
.version(VERSION)
|
||||||
.accept_any(),
|
.about(SUMMARY)
|
||||||
);
|
.get_matches();
|
||||||
|
|
||||||
match get_userlogin() {
|
match get_userlogin() {
|
||||||
Some(userlogin) => println!("{}", userlogin),
|
Some(userlogin) => println!("{}", userlogin),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue