some naming adjustments
This commit is contained in:
parent
70f2854098
commit
ac03c35eb6
4 changed files with 24 additions and 8 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -1,3 +1,4 @@
|
|||
pub mod publish;
|
||||
pub mod watcher;
|
||||
|
||||
use std::{path::PathBuf, sync::mpsc};
|
||||
|
|
@ -10,8 +11,8 @@ use tracing_subscriber::EnvFilter;
|
|||
#[derive(Debug, Parser)]
|
||||
#[command(name = "lumina", version, about)]
|
||||
struct Cli {
|
||||
#[arg(short = 'f', long)]
|
||||
file: Option<PathBuf>,
|
||||
#[arg(short = 'p', long)]
|
||||
path: Option<PathBuf>,
|
||||
#[arg(short = 'v', long)]
|
||||
verbose: bool,
|
||||
}
|
||||
|
|
@ -39,14 +40,14 @@ fn main() -> Result<()> {
|
|||
.with_timer(timer)
|
||||
.init();
|
||||
|
||||
if let Some(file) = args.file {
|
||||
if let Some(path) = args.path {
|
||||
let (tx, rx) = mpsc::channel::<Result<Event>>();
|
||||
// Automatically select the best implementation for your platform.
|
||||
let mut watcher = notify::recommended_watcher(tx)?;
|
||||
watcher.watch(&file, RecursiveMode::Recursive)?;
|
||||
watcher.watch(&path, RecursiveMode::Recursive)?;
|
||||
for res in rx {
|
||||
match res {
|
||||
Ok(event) => match watcher::watch(event) {
|
||||
Ok(event) => match watcher::watch(event, &path) {
|
||||
Ok(()) => (),
|
||||
Err(e) => error!("internal error: {:?}", e),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use std::io::Error as IOError;
|
||||
use std::path::{Path, PathBuf};
|
||||
pub struct Project {
|
||||
name: String,
|
||||
base_directory: PathBuf,
|
||||
|
|
@ -22,3 +24,14 @@ pub enum Action {
|
|||
Attach,
|
||||
Copy,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
ParseError(PathBuf),
|
||||
InternalError,
|
||||
IO(IOError),
|
||||
}
|
||||
|
||||
pub fn build_site(path: impl AsRef<Path>) -> Result<(), Error> {
|
||||
todo!()
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use notify::{Event, EventKind, Result};
|
||||
use tracing::debug;
|
||||
|
||||
pub fn watch(event: Event) -> Result<()> {
|
||||
pub fn watch(event: Event, path: impl AsRef<Path>) -> Result<()> {
|
||||
if event
|
||||
.paths
|
||||
.clone()
|
||||
|
|
@ -11,7 +11,8 @@ pub fn watch(event: Event) -> Result<()> {
|
|||
.filter(|e| {
|
||||
if let Some(base_name) = e.file_name() {
|
||||
let name = base_name.to_os_string().into_string().unwrap_or("".into());
|
||||
!name.starts_with(".#")
|
||||
// Let's filter out emacs changes and lockfiles
|
||||
!(name.starts_with(".#") | name.ends_with("~"))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
@ -22,6 +23,7 @@ pub fn watch(event: Event) -> Result<()> {
|
|||
{
|
||||
match event.kind {
|
||||
EventKind::Create(_) | EventKind::Modify(_) | EventKind::Remove(_) => {
|
||||
// rebuild function
|
||||
debug!(?event);
|
||||
for path in event.paths {
|
||||
if !path.exists() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue