added c-main dependency

This commit is contained in:
2023-03-25 00:46:37 -04:00
parent 03e02b9882
commit 19e5f4e2f4
3 changed files with 19 additions and 9 deletions

View File

@@ -16,8 +16,9 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
#![no_main]
use std::{
env,
fs::File,
io::Read,
iter::Peekable,
@@ -26,6 +27,7 @@ use std::{
str::FromStr,
};
use c_main::Args;
use toml::Value;
use yacexits::*;
@@ -97,8 +99,9 @@ fn parse_toml(
Ok(out)
}
fn main() {
let argv: Vec<String> = env::args().collect();
#[no_mangle]
fn rust_main(args: Args) {
let argv: Vec<&str> = args.into_iter().collect();
let usage_info = format!("Usage: {} [table.]key[[index]] [file...]", argv[0]);
if argv.len() <= 1 {
@@ -106,15 +109,11 @@ fn main() {
exit(EX_USAGE);
}
let input: &str;
if let Some(arg) = argv.get(2) {
input = arg;
} else { input = &""; }
let input = argv.get(2).unwrap_or(&"");
let mut content = Vec::new();
match input {
match input.to_owned() {
"-" | "" => unsafe { File::from_raw_fd(0) },
_ => {
File::open(Path::new(&input)).unwrap_or_else(|_| {