diff --git a/src/command/format.rs b/src/cli/format.rs similarity index 98% rename from src/command/format.rs rename to src/cli/format.rs index 409d809..8582789 100644 --- a/src/command/format.rs +++ b/src/cli/format.rs @@ -1,8 +1,8 @@ -use crate::engine::run_treefmt; use anyhow::anyhow; use directories::ProjectDirs; use log::debug; use std::path::{Path, PathBuf}; +use treefmt::engine::run_treefmt; pub fn format_cmd( tree_root: &Option, diff --git a/src/command/format_stdin.rs b/src/cli/format_stdin.rs similarity index 96% rename from src/command/format_stdin.rs rename to src/cli/format_stdin.rs index 9466513..caaeb08 100644 --- a/src/command/format_stdin.rs +++ b/src/cli/format_stdin.rs @@ -1,10 +1,8 @@ -use crate::config; -use crate::engine::run_treefmt_stdin; -use crate::expand_path; use anyhow::anyhow; use directories::ProjectDirs; use log::debug; use std::path::{Path, PathBuf}; +use treefmt::{config, engine::run_treefmt_stdin, expand_path}; pub fn format_stdin_cmd( tree_root: &Option, diff --git a/src/command/init.rs b/src/cli/init.rs similarity index 90% rename from src/command/init.rs rename to src/cli/init.rs index 0a21339..913d22c 100644 --- a/src/command/init.rs +++ b/src/cli/init.rs @@ -1,9 +1,8 @@ -use crate::config; use anyhow::Context; use console::style; use log::info; -use std::fs; -use std::path::Path; +use std::{fs, path::Path}; +use treefmt::config; pub fn init_cmd(work_dir: &Path) -> anyhow::Result<()> { let file_path = work_dir.join(config::FILENAME); diff --git a/src/command/init_treefmt.toml b/src/cli/init_treefmt.toml similarity index 100% rename from src/command/init_treefmt.toml rename to src/cli/init_treefmt.toml diff --git a/src/command/mod.rs b/src/cli/mod.rs similarity index 99% rename from src/command/mod.rs rename to src/cli/mod.rs index 3bf9805..48e1c56 100644 --- a/src/command/mod.rs +++ b/src/cli/mod.rs @@ -8,8 +8,6 @@ mod init; use self::format::format_cmd; use self::format_stdin::format_stdin_cmd; use self::init::init_cmd; -use crate::config; -use crate::expand_path; use anyhow::anyhow; use clap::Parser; use clap_verbosity_flag::Verbosity; @@ -17,6 +15,7 @@ use std::{ env, path::{Path, PathBuf}, }; +use treefmt::{config, expand_path}; /// ✨ format all your language! #[derive(Parser, Debug)] diff --git a/src/lib.rs b/src/lib.rs index 9cb981b..30978ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,5 @@ //! Your favorite all-in-one formatter tool! -#![deny(missing_docs)] -pub mod command; pub mod config; pub mod engine; pub mod eval_cache; @@ -11,9 +9,11 @@ use anyhow::Result; use filetime::FileTime; use path_clean::PathClean; use serde::{Deserialize, Serialize}; -use std::env; -use std::fs::Metadata; -use std::path::{Path, PathBuf}; +use std::{ + env, + fs::Metadata, + path::{Path, PathBuf}, +}; use which::which_in; /// FileMeta represents file meta that change on file modification diff --git a/src/main.rs b/src/main.rs index 47b595c..a5d5385 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,9 @@ #![allow(clippy::redundant_closure, clippy::redundant_pattern_matching)] +mod cli; + +use crate::cli::{cli_from_args, run_cli}; use log::error; -use treefmt::command::{cli_from_args, run_cli}; fn main() { if let Err(e) = run() {