diff --git a/Cargo.lock b/Cargo.lock index cf77c05..a0d60b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,10 +2,105 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "clap" +version = "4.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "devious_rust" version = "0.1.0" dependencies = [ + "clap", "serde", "serde_yaml", ] @@ -22,6 +117,12 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "indexmap" version = "2.2.5" @@ -95,6 +196,12 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "syn" version = "2.0.53" @@ -117,3 +224,75 @@ name = "unsafe-libyaml" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" diff --git a/Cargo.toml b/Cargo.toml index 37e580f..8a970d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,4 @@ edition = "2021" [dependencies] serde = { version = "1.0", features = ["derive"] } serde_yaml = "0.9" -# git-discover = "0.13.1" \ No newline at end of file +clap = {version = "4.4.17", features = ["derive"]} \ No newline at end of file diff --git a/src/cmd/init_cmd.rs b/src/cmd/init_cmd.rs index e69de29..95fcbdf 100644 --- a/src/cmd/init_cmd.rs +++ b/src/cmd/init_cmd.rs @@ -0,0 +1,22 @@ +use crate::internal::git::repo; +use crate::internal::storage::init; +use std::path::PathBuf; + +fn get_init_runner(storage_dir: &PathBuf, mode: u32, gid: u32) -> Result<(), std::io::Error> { + + let git_repo = match repo::get_nearest_repo_dir(storage_dir) { + Ok(git_repo) => { + // json + git_repo + } + Err(e) => { + // json + return Err(e) + } + }; + + let init_run = init::init(&git_repo, &storage_dir, &mode, &gid); + + + +} \ No newline at end of file diff --git a/src/internal/git/repo.rs b/src/internal/git/repo.rs index afe73f3..d74bf17 100644 --- a/src/internal/git/repo.rs +++ b/src/internal/git/repo.rs @@ -12,7 +12,7 @@ fn is_git_repo(dir: &PathBuf) -> bool { dir.join(".git").is_dir() } -pub fn get_nearest_repo_dir(dir: PathBuf) -> Result { +pub fn get_nearest_repo_dir(dir: &PathBuf) -> Result { let mut directory = match dir.canonicalize() { Ok(directory) => directory, Err(e) => return Err(e) diff --git a/src/internal/storage/init.rs b/src/internal/storage/init.rs index c14b0d4..dee8946 100644 --- a/src/internal/storage/init.rs +++ b/src/internal/storage/init.rs @@ -11,7 +11,7 @@ use std::fs::Permissions; -fn init(root_dir: PathBuf, storage_dir: PathBuf, mode: u32, gid: u32) -> Result<(), std::io::Error> { // +pub fn init(root_dir: &PathBuf, storage_dir: &PathBuf, mode: &u32, gid: &u32) -> Result<(), std::io::Error> { // // get storage directory as an absolute path let storage_dir_abs: PathBuf = match storage_dir.canonicalize() { Ok(storage_dir_abs) => { diff --git a/src/main.rs b/src/main.rs index 86fac9a..43233c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,23 +1,33 @@ use std::path::PathBuf; use std::env; +use clap::{arg, Command, ArgAction, Arg}; +use std::io; mod internal; use crate::internal::storage::init; use crate::internal::config::config; use crate::internal::git::repo; -// use git_discover; - mod cmd; use crate::cmd::init_cmd; -fn main() { +fn main() -> io::Result<()> { + let intro = Command::new("🌀 Devious") + .version("0.0.1") + .author("Andriy Massimilla, Jenna Johnson") + .about("version large files under Git") + .arg_required_else_help(false) + .get_matches(); + + + + + + let current = env::current_dir().unwrap().display().to_string(); println!("{current}"); - let nearest_repo = repo::get_nearest_repo_dir(PathBuf::from(r"src")).unwrap().display().to_string(); + let nearest_repo = repo::get_nearest_repo_dir(&PathBuf::from(r"src")).unwrap().display().to_string(); println!("NEAREST PATH: {nearest_repo}"); - - let dir = PathBuf::from("/cluster-data/user-homes/jenna/Projects/devious/src"); let config = config::Config{storage_dir: dir.clone()};