updated main()
This commit is contained in:
parent
570adfc17d
commit
49691bd68c
|
@ -370,15 +370,6 @@ version = "0.2.140"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc-print"
|
|
||||||
version = "0.1.21"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "06cea5d58bd9ba4717bbf5c6c5bb11bb6e9e76685b7fff34039b80f50ce86c11"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
version = "0.7.4"
|
version = "0.7.4"
|
||||||
|
@ -1009,12 +1000,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yacexits"
|
name = "yacexits"
|
||||||
version = "0.2.0"
|
version = "0.1.5"
|
||||||
source = "git+https://git.tebibyte.media/yac/yacexits.git?branch=c-entry#d2af983f4ad18dec2af0604d7f34b7863daa5c25"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53fe740dd05c1bbc919431e842e6c1bea30195e0518ae99cae35b7f0730ddc18"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"libc",
|
"libc",
|
||||||
"libc-print",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -22,4 +22,4 @@ serde_json = "1"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
toml = "0.7.3"
|
toml = "0.7.3"
|
||||||
xdg = "2.4.1"
|
xdg = "2.4.1"
|
||||||
yacexits = { git = "https://git.tebibyte.media/yac/yacexits.git", branch = "c-entry", version = "0.2.0" }
|
yacexits = "0.1.5"
|
||||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -19,8 +19,6 @@
|
||||||
* Hopper. If not, see <https://www.gnu.org/licenses/>.
|
* Hopper. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#![no_main]
|
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
mod args;
|
mod args;
|
||||||
mod client;
|
mod client;
|
||||||
|
@ -33,9 +31,13 @@ use client::*;
|
||||||
use config::*;
|
use config::*;
|
||||||
use hopfile::*;
|
use hopfile::*;
|
||||||
|
|
||||||
|
use std::env::args;
|
||||||
|
|
||||||
use yacexits::{
|
use yacexits::{
|
||||||
|
exit,
|
||||||
EX_OSERR,
|
EX_OSERR,
|
||||||
EX_SOFTWARE,
|
EX_SOFTWARE,
|
||||||
|
EX_USAGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AppContext {
|
struct AppContext {
|
||||||
|
@ -43,12 +45,26 @@ struct AppContext {
|
||||||
config: Config,
|
config: Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
#[no_mangle]
|
|
||||||
async fn rust_main(arguments: yacexits::Args) -> Result<u32, (String, u32)> {
|
|
||||||
let argv: Vec<&str> = arguments.into_iter().collect();
|
|
||||||
|
|
||||||
let args = Arguments::from_args(argv.clone().into_iter())
|
fn main() {
|
||||||
|
let argv = args().collect::<Vec<String>>();
|
||||||
|
match rust_main(argv.clone()) {
|
||||||
|
Ok(code) => exit(code),
|
||||||
|
Err((message, code)) => {
|
||||||
|
if code == EX_USAGE {
|
||||||
|
eprintln!("Usage: {} {}", argv[0], message);
|
||||||
|
} else {
|
||||||
|
eprintln!("{}: {}", argv[0], message);
|
||||||
|
}
|
||||||
|
exit(code);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn rust_main(argv: Vec<String>) -> Result<u32, (String, u32)> {
|
||||||
|
|
||||||
|
let args = Arguments::from_args(argv.clone().iter().map(|s| s.as_str()))
|
||||||
.map_err(|err| { ArgsError::from(err) })?;
|
.map_err(|err| { ArgsError::from(err) })?;
|
||||||
|
|
||||||
let config = Config::read_config()?;
|
let config = Config::read_config()?;
|
||||||
|
|
Loading…
Reference in New Issue