Skip to content

Commit

Permalink
use uzers instead of users crate
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed Nov 28, 2023
1 parent 7382ee4 commit d245781
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
postgres = "0.19"
postgres-native-tls = "0.5"
getopts = "0.2"
users = "0.11"
uzers = "0.11"
chrono = { git = "https://github.com/chronotope/chrono", rev = "1a0d47a3e58eeb44e2b5022547262650d1a7a436", features = ["clock"] }
regex = "1"
lazy_static = "1.0"
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{env, process, thread};
use std::time::Duration;
use postgres::{Client, NoTls};
use getopts::Options;
use users::{get_current_uid, get_user_by_uid};
use uzers::{Users, UsersCache};
use regex::Regex;
use chrono::prelude::*;

Expand Down Expand Up @@ -278,10 +278,12 @@ fn main() {
};
let user = match matches.opt_str("user") {
Some(v) => v,
None => get_user_by_uid(get_current_uid())
.expect("fail get uid")
.name()
.to_os_string().into_string().expect("get user"),
None => {
let cache = UsersCache::new();
let uid = cache.get_current_uid();
let user = cache.get_user_by_uid(uid).expect("fail get uid");
user.name().to_string_lossy().to_string()
},
};
let password = match matches.opt_str("password") {
Some(v) => v,
Expand Down

0 comments on commit d245781

Please sign in to comment.