Skip to content

Commit

Permalink
feat(ark-cli): add command ark-cli watch
Browse files Browse the repository at this point in the history
Implement `ark-cli watch` command using `ResourceId::watch_index()`.

This command monitors a specified directory for file system changes and updates the index automatically.

Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Apr 22, 2024
1 parent 51c2ee5 commit de28f05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ark-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ async fn main() -> anyhow::Result<()> {
let img = render_preview_page(buf, quality);
img.save(dest_path).unwrap();
}
Command::Watch { path } => {
let canonicalized_path = std::fs::canonicalize(path.clone())?;
println!("Watching path: {:?}", canonicalized_path);
fs_index::watch::watch_index(path.clone()).await?;
}
Command::Link(link) => match &link {
Link::Create {
root_dir,
Expand Down
12 changes: 12 additions & 0 deletions ark-cli/src/models/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ pub enum Command {
filter: Option<String>,
},

#[clap(
about = "Watch a directory for changes and update the index automatically"
)]
Watch {
#[clap(
help = "Path to the directory to watch for changes",
default_value = ".",
value_parser
)]
path: PathBuf,
},

#[clap(subcommand)]
Link(Link),

Expand Down

0 comments on commit de28f05

Please sign in to comment.