mirror of
https://codeberg.org/icewind/galton.git
synced 2026-06-03 18:34:08 +02:00
homemanager module
This commit is contained in:
parent
09de7e6f00
commit
0e572744bf
5 changed files with 108 additions and 5 deletions
|
|
@ -39,7 +39,7 @@ impl WatchConfig {
|
|||
}
|
||||
}
|
||||
|
||||
fn normalize_path<P: Into<String> + AsRef<str>>(path: P) -> String {
|
||||
pub fn normalize_path<P: Into<String> + AsRef<str>>(path: P) -> String {
|
||||
if let Some(suffix) = path.as_ref().strip_prefix("~/") {
|
||||
let home = home_dir().unwrap_or_default();
|
||||
home.join(suffix)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::config::GaltonConfig;
|
||||
use crate::config::{normalize_path, GaltonConfig};
|
||||
use crate::file::FileInfo;
|
||||
use crate::rule::{Rule, RuleMatch};
|
||||
use clap::builder::styling::{AnsiColor, Effects};
|
||||
|
|
@ -44,12 +44,12 @@ enum Commands {
|
|||
/// Apply rules on a single file
|
||||
File {
|
||||
/// Path to apply rules on
|
||||
path: PathBuf,
|
||||
path: String,
|
||||
},
|
||||
/// Watch for new files and apply rules on them
|
||||
Watch {
|
||||
/// Directory to watch for new files
|
||||
path: PathBuf,
|
||||
path: String,
|
||||
#[arg(long)]
|
||||
recursive: bool,
|
||||
},
|
||||
|
|
@ -66,6 +66,7 @@ fn main() -> MainResult {
|
|||
handle_file(&file, &config.rule);
|
||||
}
|
||||
Commands::Watch { path, recursive } => {
|
||||
let path = normalize_path(path);
|
||||
let rules = config.rule;
|
||||
let symlink = config.watch.symlink();
|
||||
let (tx, rx) = channel();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue