diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1,6 +1,11 @@ +#![feature(once_cell)] + +mod args; +mod error; mod logger; mod theming; +use crate::args::parse_args; use crate::logger::LogItem; use crate::theming::{curses_attr, parse_attrs}; @@ -8,6 +13,7 @@ use chrono::{Datelike, Timelike}; use pyo3::{ conversion::{IntoPy, ToPyObject}, create_exception, + exceptions::PyIOError, marker::Python, prelude::{pyfunction, pymodule, wrap_pyfunction, PyErr, PyModule, PyObject, PyResult}, types::{PyDateTime, PyDict}, @@ -20,6 +26,7 @@ fn libpoezio(py: Python, m: &PyModule) -> PyResult<()> { m.add("LogParseError", py.get_type::<LogParseError>())?; m.add_function(wrap_pyfunction!(to_curses_attr, m)?)?; m.add_function(wrap_pyfunction!(parse_logs, m)?)?; + m.add_function(wrap_pyfunction!(run_cmdline_args, m)?)?; Ok(()) } @@ -86,3 +93,9 @@ fn parse_logs(py: Python, input: &str) -> PyResult<PyObject> { } Ok(items.into_py(py).to_object(py)) } + +#[pyfunction] +fn run_cmdline_args(py: Python, argv: Vec<String>) -> PyResult<(PyObject, bool)> { + let (args, firstrun) = parse_args(argv).map_err(|err| PyIOError::new_err(err.to_string()))?; + Ok((args.into_py(py), firstrun)) +} |