Skip to main content

breezyshim/
github.rs

1//! Basic support for interacting with GitHub.
2use pyo3::prelude::*;
3
4/// Retrieve a GitHub authentication token.
5pub fn retrieve_github_token() -> String {
6    Python::attach(|py| {
7        let m = py.import("breezy.plugins.github.forge").unwrap();
8
9        let token = m.call_method0("retrieve_github_token").unwrap();
10
11        token.extract().unwrap()
12    })
13}
14
15/// Login to GitHub using saved credentials.
16pub fn login() -> PyResult<()> {
17    Python::attach(|py| {
18        let m = py.import("breezy.plugins.github.cmds").unwrap();
19        let cmd = m.getattr("cmd_github_login").unwrap();
20
21        let cmd_gl = cmd.call0().unwrap();
22        cmd_gl.call_method0("_setup_outf").unwrap();
23
24        cmd_gl.call_method0("run").unwrap();
25
26        Ok(())
27    })
28}