#parser #netrc #libary #utils #netrc-parser

netrc_util

A simple libary for parsing netrc files

1 unstable release

0.1.0 Mar 21, 2024

#6 in #libary

Download history 131/week @ 2024-03-18 22/week @ 2024-04-01

153 downloads per month

MIT license

23KB
577 lines

netrc_util

A simple libary for parsing netrc files.

Usage

use netrc_util::{Host, NetrcParser};

fn main() {
    let netrc_content = "machine sample.test login user password pass";
    let host = Host::parse("sample.test").unwrap();

    let entry = NetrcParser::new(netrc_content).entry_for_host(&host).unwrap().unwrap();

    assert_eq!(entry.login(), Some("login"));
    assert_eq!(entry.password(), Some("pass"));
}

lib.rs:

netrc_util

A simple libary for parsing netrc files.

Usage

use netrc_util::{Host, NetrcParser};

let netrc_content = "machine sample.test login user password pass";
let host = Host::parse("sample.test").unwrap();

let entry = NetrcParser::new(netrc_content.as_bytes())
    .entry_for_host(&host)
    .unwrap()
    .unwrap();

assert_eq!(entry.login(), Some("user".to_string()).as_ref());
assert_eq!(entry.password(), "pass");

Dependencies

~3MB
~79K SLoC