diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2022-08-21 22:53:40 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2022-08-23 11:44:11 +0200 |
commit | 10cc67e6c78ca37508ba30cba42baa68c8fff5a3 (patch) | |
tree | 35a040ed084f389937675218341ff7d2319315d4 /src/lib.rs | |
parent | c68b00ae248476751935499dbe5fb151e2919569 (diff) | |
download | poezio-10cc67e6c78ca37508ba30cba42baa68c8fff5a3.tar.gz poezio-10cc67e6c78ca37508ba30cba42baa68c8fff5a3.tar.bz2 poezio-10cc67e6c78ca37508ba30cba42baa68c8fff5a3.tar.xz poezio-10cc67e6c78ca37508ba30cba42baa68c8fff5a3.zip |
roezio: migrate poezio/args.py
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
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)) +} |