From 88c50bf92791240368576e3c65114d47bb358122 Mon Sep 17 00:00:00 2001 From: Alberto Paparelli Date: Fri, 27 Dec 2024 15:30:06 +0100 Subject: [PATCH] changes from notes to directory --- Cargo.toml | 2 +- README.md | 45 ++++++++++++++++++++++++--------------------- src/config.rs | 22 +++++++++++----------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 569d48d..6add9f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "notesync" +name = "gitsync" version = "0.1.0" edition = "2021" diff --git a/README.md b/README.md index 72d7b94..87896ca 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,20 @@ -# Notes Sync +# GitSync -![Rust CI](https://github.com/carpe-diem/notes-sync/actions/workflows/rust.yml/badge.svg) - - +![Rust CI](https://github.com/carpe-diem/git-sync/actions/workflows/rust.yml/badge.svg) + + [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](LICENSE) [![Rust Version](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://www.rust-lang.org) -[![dependency status](https://deps.rs/repo/github/carpe-diem/notes-sync/status.svg)](https://deps.rs/repo/github/carpe-diem/notes-sync) - +[![dependency status](https://deps.rs/repo/github/carpe-diem/git-sync/status.svg)](https://deps.rs/repo/github/carpe-diem/git-sync) + + +A simple CLI tool to synchronize any directory with GitHub. Keep your files backed up and accessible across multiple devices using Git as the synchronization mechanism. -A simple application to synchronize your notes with GitHub. Keep your notes backed up and accessible across multiple devices using Git as the synchronization mechanism. ## Features -- ... +- Synchronization with GitHub repositories +- Two-way sync between local directory and remote repository +- Simple configuration and setup ## TODO - Automatic synchronization with GitHub repositories. @@ -20,15 +23,15 @@ A simple application to synchronize your notes with GitHub. Keep your notes back ## Description -Notes Sync is a tool designed to help you maintain your notes organized and synchronized using GitHub as a backend. It watches for changes in your local notes directory and automatically commits and pushes changes to your configured GitHub repository. +GitSync is a tool designed to help you maintain your notes organized and synchronized using GitHub as a backend. It watches for changes in your local notes directory and automatically commits and pushes changes to your configured GitHub repository. ## Usage ```bash # Initial setup -notesync setup +gitsync setup # Sync your notes -notesync sync +gitsync sync ``` ## Installation @@ -40,27 +43,27 @@ notesync sync 2. Clone and build the project: ```bash git clone [repository-url] - cd notes-sync + cd git-sync cargo build --release ``` -3. The binary will be available at `target/release/notesync` +3. The binary will be available at `target/release/gitsync` ## Configuration Run the setup command and follow the prompts: ```bash -notesync setup +gitsync setup ``` You'll need to provide: - GitHub Personal Access Token (with repo permissions) - GitHub repository (format: username/repo) -- Path to your Notes folder +- Path to your directory to sync ## Project Structure ``` -notes-sync +git-sync ├── .github // GitHub Actions configuration ├── src │ ├── main.rs // Application entry point @@ -105,15 +108,15 @@ pre-commit run --all-files ### Building ```bash -cargo build # Debug build -cargo build --release # Release build +cargo build # Debug build +cargo build --release # Release build ``` ### Testing ```bash -cargo test # Run all tests -cargo test config # Run tests for config module only -cargo test -- --nocapture # Run tests and show println output +cargo test # Run all tests +cargo test config # Run tests for config module only +cargo test -- --nocapture # Run tests and show println output ``` ### Running in Development diff --git a/src/config.rs b/src/config.rs index 966b7f1..0cd107b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,7 +7,7 @@ use std::io::{self, Write}; pub struct Config { pub github_token: String, pub github_repo: String, - pub notes_path: String, + pub directory_path: String, } impl Config { @@ -28,7 +28,7 @@ impl Config { let existing_config = Self::load()?.unwrap_or(Config { github_token: String::new(), github_repo: String::new(), - notes_path: String::new(), + directory_path: String::new(), }); let config = Config { @@ -40,9 +40,9 @@ impl Config { "Enter repository (format: username/repo)", &existing_config.github_repo, )?, - notes_path: prompt_with_default( - "Enter path to your Notes folder", - &existing_config.notes_path, + directory_path: prompt_with_default( + "Enter path to your directory to sync", + &existing_config.directory_path, )?, }; @@ -111,7 +111,7 @@ mod tests { let config = Config { github_token: "test_token".to_string(), github_repo: "user/repo".to_string(), - notes_path: "/path/to/notes".to_string(), + directory_path: "/path/to/notes".to_string(), }; let serialized = serde_json::to_string(&config).unwrap(); @@ -119,7 +119,7 @@ mod tests { assert_eq!(config.github_token, deserialized.github_token); assert_eq!(config.github_repo, deserialized.github_repo); - assert_eq!(config.notes_path, deserialized.notes_path); + assert_eq!(config.directory_path, deserialized.directory_path); } #[test] @@ -132,7 +132,7 @@ mod tests { let test_config = Config { github_token: "temp_token".to_string(), github_repo: "temp/repo".to_string(), - notes_path: "/temp/path".to_string(), + directory_path: "/temp/path".to_string(), }; // Save config directly to temp file @@ -146,7 +146,7 @@ mod tests { // Verify contents assert_eq!(test_config.github_token, loaded_config.github_token); assert_eq!(test_config.github_repo, loaded_config.github_repo); - assert_eq!(test_config.notes_path, loaded_config.notes_path); + assert_eq!(test_config.directory_path, loaded_config.directory_path); // TempDir will be automatically cleaned up when it goes out of scope Ok(()) @@ -207,11 +207,11 @@ mod tests { let config = Config { github_token: String::new(), github_repo: String::new(), - notes_path: String::new(), + directory_path: String::new(), }; assert!(config.github_token.is_empty()); assert!(config.github_repo.is_empty()); - assert!(config.notes_path.is_empty()); + assert!(config.directory_path.is_empty()); } }