toggle offline/online mode

This commit is contained in:
2023-03-08 20:46:03 +01:00
parent f03b676313
commit e73f186b0f
3 changed files with 26 additions and 9 deletions

View File

@ -8,7 +8,10 @@ mod opt;
pub mod parser;
mod playlist;
use std::{io::{stdin, stdout, Stdin, StdoutLock, Write}, rc::Rc};
use std::{
io::{stdin, stdout, Stdin, StdoutLock, Write},
rc::Rc,
};
use async_recursion::async_recursion;
pub use config::Configuration;
@ -65,10 +68,10 @@ pub async fn get_gm(
mode: Mode,
readline: &mut Readline<'_>,
config: Rc<Configuration>,
) -> Result<GrandMother, String> {
) -> Result<(GrandMother, bool), String> {
match mode {
Mode::Online => GrandMother::new_online(config).await,
Mode::Offline => Ok(GrandMother::new_offline(config)),
Mode::Online => Ok((GrandMother::new_online(config).await?, true)),
Mode::Offline => Ok((GrandMother::new_offline(config), false)),
Mode::Ask => loop {
let input = readline
.input("Online/Offline mode? [1/2] ")