Skip to content

Commit

Permalink
feat(cli): add auto watch for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 7, 2021
1 parent c82cbbd commit 4bcb773
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ pub struct Terminal {}
pub struct WebServer {
#[clap(short, long, default_value = ".quake.yaml")]
config: String,

#[clap(short, long)]
/// auto watch entry change, and feed to search engine
watch: bool,
}

#[derive(Parser)]
Expand Down Expand Up @@ -91,13 +95,18 @@ pub async fn process_cmd(opts: Opts) -> Result<(), Box<dyn Error>> {
let config = load_config(&server.config)?;
let path = config.workspace;
let search_url = config.search_url;
futures::executor::block_on(async {
let (_s, _g) = future::join(
quake_rocket().launch(),
entry_watcher::async_watch(path, search_url),
)
.await;
});

if server.watch {
futures::executor::block_on(async {
let (_s, _g) = future::join(
quake_rocket().launch(),
entry_watcher::async_watch(path, search_url),
)
.await;
});
} else {
let _ = futures::executor::block_on(async { quake_rocket().launch() }).await;
}
}
SubCommand::Tui(_) => {
tui_main_loop()?;
Expand Down

0 comments on commit 4bcb773

Please sign in to comment.