blob: 7f3b90d2c671451845778652cdd4595f3260a6e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use anyhow::{Context, Result};
use clap::Parser;
use projectr::{project::ProjectItem, Config};
use tokio::signal;
#[tokio::main]
async fn main() -> Result<()> {
let cli = Config::parse();
tracing_subscriber::fmt::fmt()
.pretty()
.with_writer(std::io::stderr)
.with_max_level(&cli.verbosity)
.init();
let res = tokio::select! {
res = signal::ctrl_c() => res.map_err(Into::into),
res = run(cli) => res.context("Failed to run projectr"),
};
res
}
#[tracing::instrument]
pub async fn run(config: Config) -> Result<()> {
let mut projects: Vec<ProjectItem> = config.search.into_iter().collect();
projects.sort_unstable_by_key(|p| *p.timestamp());
for project in projects {
println!("{}", project.to_path_buf().to_string_lossy())
}
Ok(())
}
|