mirror of
https://git.sr.ht/~spicywolf/k2spice
synced 2025-01-31 07:51:53 +00:00
Compare commits
No commits in common. "a31dea4d846f6574263d266106d482f88d46d051" and "80b2dd31531f24b070a83f2d56670249b58c6f4b" have entirely different histories.
a31dea4d84
...
80b2dd3153
|
@ -8,14 +8,10 @@ tasks:
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
|
||||||
source "$HOME/.cargo/env"
|
source "$HOME/.cargo/env"
|
||||||
rustup toolchain install nightly --allow-downgrade --profile minimal --component clippy
|
rustup toolchain install nightly --allow-downgrade --profile minimal --component clippy
|
||||||
- bld-dbg: |
|
- build: |
|
||||||
cd k2spice
|
cd k2spice
|
||||||
source "$HOME/.cargo/env"
|
source "$HOME/.cargo/env"
|
||||||
cargo build
|
cargo build
|
||||||
- bld-rel: |
|
|
||||||
cd k2spice
|
|
||||||
source "$HOME/.cargo/env"
|
|
||||||
cargo build --release
|
|
||||||
- test: |
|
- test: |
|
||||||
cd k2spice
|
cd k2spice
|
||||||
source "$HOME/.cargo/env"
|
source "$HOME/.cargo/env"
|
|
@ -1,26 +0,0 @@
|
||||||
image: debian/stable
|
|
||||||
environment:
|
|
||||||
RUSTFLAGS: -D warnings
|
|
||||||
sources:
|
|
||||||
- https://git.sr.ht/~spicywolf/k2spice
|
|
||||||
tasks:
|
|
||||||
- rustup: |
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
|
|
||||||
source "$HOME/.cargo/env"
|
|
||||||
rustup toolchain install nightly --allow-downgrade --profile minimal --component clippy
|
|
||||||
- bld-dbg: |
|
|
||||||
cd k2spice
|
|
||||||
source "$HOME/.cargo/env"
|
|
||||||
cargo build
|
|
||||||
- bld-rel: |
|
|
||||||
cd k2spice
|
|
||||||
source "$HOME/.cargo/env"
|
|
||||||
cargo build --release
|
|
||||||
- test: |
|
|
||||||
cd k2spice
|
|
||||||
source "$HOME/.cargo/env"
|
|
||||||
cargo test
|
|
||||||
- clippy: |
|
|
||||||
cd k2spice
|
|
||||||
source "$HOME/.cargo/env"
|
|
||||||
cargo clippy
|
|
|
@ -8,7 +8,6 @@ members = [
|
||||||
"usr/src/mei/printf",
|
"usr/src/mei/printf",
|
||||||
"usr/src/mei/false",
|
"usr/src/mei/false",
|
||||||
"usr/src/mei/hostname",
|
"usr/src/mei/hostname",
|
||||||
"usr/src/lib/com",
|
|
||||||
]
|
]
|
||||||
default-members = [
|
default-members = [
|
||||||
"usr/src/mei/true",
|
"usr/src/mei/true",
|
||||||
|
@ -34,3 +33,4 @@ readme = "README.md"
|
||||||
nix = "0.27"
|
nix = "0.27"
|
||||||
clap = { version = "4.4.8", features = ["derive"] }
|
clap = { version = "4.4.8", features = ["derive"] }
|
||||||
serde = { version = "1.0.192", features = ["derive"] }
|
serde = { version = "1.0.192", features = ["derive"] }
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "com"
|
|
||||||
version.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
authors.workspace = true
|
|
||||||
description.workspace = true
|
|
||||||
documentation.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
readme.workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License, Version 1.0 only
|
|
||||||
* (the "License"). You may not use this file except in compliance
|
|
||||||
* with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2023 Skylar Alexandra Bleed. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** like a prelude: use com::macros::*; */
|
|
||||||
pub mod macros {
|
|
||||||
pub use crate::{ok_or, some_or, fatal};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** print an error and abort */
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! fatal {
|
|
||||||
($($t:tt)*) => {{
|
|
||||||
eprintln!("fatal error: {}", format!($($t)*));
|
|
||||||
std::process::exit(-1);
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** expect an Ok value or abort */
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! ok_or {
|
|
||||||
($x:expr, $($t:tt)*) => {{
|
|
||||||
match $x {
|
|
||||||
Ok(x) => x,
|
|
||||||
Err(e) => fatal!("{e}: {}", format!($($t)*)),
|
|
||||||
}
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** expect a Some value or abort */
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! some_or {
|
|
||||||
($x:expr, $($t:tt)*) => {{
|
|
||||||
match $x {
|
|
||||||
Some(x) => x,
|
|
||||||
None => fatal!($($t)*),
|
|
||||||
}
|
|
||||||
}};
|
|
||||||
}
|
|
|
@ -16,4 +16,3 @@ path = "src/pwd.rs"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
com = { path = "../../lib/com" }
|
|
||||||
|
|
|
@ -22,20 +22,18 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023 Ren Kararou All rights reserved.
|
* Copyright 2023 Ren Kararou All rights reserved.
|
||||||
* Portions copyright Skylar Alexandra Bleed 2024. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::env::current_dir;
|
use std::env::current_dir;
|
||||||
use com::macros::*;
|
use std::process::exit;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
/* TODO: make expect accept different error codes? */
|
if let Ok(buf) = current_dir() {
|
||||||
|
println!("{}", buf.to_str().expect("pwd: cannot determine current directoy!"));
|
||||||
/* buf */
|
exit(0);
|
||||||
let b = ok_or!(current_dir(), "pwd: cannot determine current directory!");
|
} else {
|
||||||
/* path */
|
eprintln!("pwd: cannot determine current directory!");
|
||||||
let p = some_or!(b.to_str(), "pwd: cannot get path from buf!");
|
exit(2);
|
||||||
|
}
|
||||||
println!("{p}");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue