diff options
author | Ren Kararou <[email protected]> | 2024-07-13 00:05:42 -0500 |
---|---|---|
committer | Ren Kararou <[email protected]> | 2024-07-13 00:05:42 -0500 |
commit | 2355137d412f48379d3fc81d6b727a786e0b765d (patch) | |
tree | f9af0aaf00cda62e8109b7f808b881c67da76a67 /usr/src/mei | |
parent | 80b2dd31531f24b070a83f2d56670249b58c6f4b (diff) | |
download | k2spice-2355137d412f48379d3fc81d6b727a786e0b765d.tar.gz k2spice-2355137d412f48379d3fc81d6b727a786e0b765d.tar.bz2 k2spice-2355137d412f48379d3fc81d6b727a786e0b765d.zip |
add common lib, custom macros, courtesy of Skylar Bleed
Diffstat (limited to 'usr/src/mei')
-rw-r--r-- | usr/src/mei/printf/src/printf.rs | 2 | ||||
-rw-r--r-- | usr/src/mei/pwd/Cargo.toml | 1 | ||||
-rw-r--r-- | usr/src/mei/pwd/src/pwd.rs | 18 |
3 files changed, 12 insertions, 9 deletions
diff --git a/usr/src/mei/printf/src/printf.rs b/usr/src/mei/printf/src/printf.rs index 4d30c64..4180112 100644 --- a/usr/src/mei/printf/src/printf.rs +++ b/usr/src/mei/printf/src/printf.rs @@ -123,7 +123,7 @@ fn fmt(fmtstr: String, args: Vec<String>) -> String { i = xe; } } else { - formatted += &fmtstr[i..i+1]; + formatted += &fmtstr[i..i + 1]; } i += 1; } diff --git a/usr/src/mei/pwd/Cargo.toml b/usr/src/mei/pwd/Cargo.toml index 6671d1c..255fac0 100644 --- a/usr/src/mei/pwd/Cargo.toml +++ b/usr/src/mei/pwd/Cargo.toml @@ -16,3 +16,4 @@ path = "src/pwd.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +com = { path = "../../lib/com" } diff --git a/usr/src/mei/pwd/src/pwd.rs b/usr/src/mei/pwd/src/pwd.rs index b0cc40d..06816a7 100644 --- a/usr/src/mei/pwd/src/pwd.rs +++ b/usr/src/mei/pwd/src/pwd.rs @@ -22,18 +22,20 @@ /* * Copyright 2023 Ren Kararou All rights reserved. + * Portions copyright Skylar Alexandra Bleed 2024. All rights reserved. * Use is subject to license terms. */ use std::env::current_dir; -use std::process::exit; +use com::macros::*; fn main() { - if let Ok(buf) = current_dir() { - println!("{}", buf.to_str().expect("pwd: cannot determine current directoy!")); - exit(0); - } else { - eprintln!("pwd: cannot determine current directory!"); - exit(2); - } + /* TODO: make expect accept different error codes? */ + + /* buf */ + let b = ok_or!(current_dir(), "pwd: cannot determine current directory!"); + /* path */ + let p = some_or!(b.to_str(), "pwd: cannot get path from buf!"); + + println!("{p}"); } |