thot_cli/commands/project/
init.rs1use crate::result::Result;
2use clap::Args;
3use std::env;
4use std::path::PathBuf;
5use thot_local::project::project;
6
7#[derive(Debug, Args)]
8pub struct InitArgs {
9 #[clap(short, long, parse(from_os_str))]
10 root: Option<PathBuf>,
11}
12
13pub fn main(args: InitArgs, verbose: bool) -> Result {
15 let root = match args.root {
17 Some(root) => root,
18 None => match env::current_dir() {
19 Ok(dir) => dir,
20 Err(err) => return Err(err.into()),
21 },
22 };
23
24 if verbose {
25 println!("Initializing Thot project in {}", root.display());
26 }
27
28 if let Err(err) = project::init(root.as_path()) {
29 return Err(err.into());
30 }
31
32 Ok(())
33}
34
35#[cfg(test)]
36#[path = "./init_test.rs"]
37mod init_test;