chore: cleaning code
This commit is contained in:
@@ -178,7 +178,7 @@ mod tests {
|
||||
fn test_get_url_props() {
|
||||
let p = "/foo/bar";
|
||||
let u = Some("user");
|
||||
let d = String::from("http://nextcloud.com");
|
||||
// let d = String::from("http://nextcloud.com");
|
||||
let sd = String::from("https://nextcloud.com");
|
||||
let sld = String::from("https://nextcloud.example.com");
|
||||
let ld = String::from("http://nextcloud.example.com");
|
||||
|
||||
@@ -25,7 +25,7 @@ pub fn config_set(args: ConfigSetArgs) {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
write_option_in_cat(category.unwrap(), name, value);
|
||||
let _ = write_option_in_cat(category.unwrap(), name, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn find_option_in_cat(category: &str, option: &str) -> Option<String> {
|
||||
config.push("config");
|
||||
|
||||
let mut in_target_category = false;
|
||||
if let Ok(mut lines) = read::read_lines(config) {
|
||||
if let Ok(lines) = read::read_lines(config) {
|
||||
|
||||
for line in lines {
|
||||
if let Ok(line) = line {
|
||||
@@ -128,7 +128,7 @@ pub fn write_option_in_cat(category: &str, option: &str, value: &str) -> io::Res
|
||||
}
|
||||
|
||||
pub fn add_remote(name: &str, url: &str) -> io::Result<()> {
|
||||
let mut config = path::config();
|
||||
let config = path::config();
|
||||
|
||||
// check if there is already a remote with this name
|
||||
if get_remote(name).is_some()
|
||||
@@ -192,38 +192,3 @@ pub fn get_all_remote() -> Vec<(String, String)> {
|
||||
pub fn get_core(name: &str) -> Option<String> {
|
||||
find_option_in_cat("core", name)
|
||||
}
|
||||
|
||||
pub fn add_core(name: &str, value: &str) -> io::Result<()> {
|
||||
let mut config = path::nextsync();
|
||||
config.push("config");
|
||||
|
||||
let mut file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(config)?;
|
||||
|
||||
writeln!(file, "[core]")?;
|
||||
writeln!(file, "\t{} = {}", name, value)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get(var: &str) -> Option<String> {
|
||||
let mut config = path::config();
|
||||
|
||||
if let Ok(lines) = read::read_lines(config) {
|
||||
for line in lines {
|
||||
if let Ok(l) = line {
|
||||
if l.starts_with(var) {
|
||||
let (_, val) = l.split_once(" ").unwrap();
|
||||
return Some(val.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ pub fn init() {
|
||||
None => env::current_dir().unwrap(),
|
||||
};
|
||||
|
||||
// todo
|
||||
// check if dir is empty
|
||||
// if let Ok(entries) = read_folder(path.clone()) {
|
||||
// if entries.len() != 0 {
|
||||
@@ -58,6 +59,7 @@ pub fn init() {
|
||||
Err(_) => println!("Error: cannot create index"),
|
||||
}
|
||||
|
||||
// todo
|
||||
path.pop();
|
||||
path.pop();
|
||||
path.push(".nextsyncignore");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use std::error::Error;
|
||||
use std::path::PathBuf;
|
||||
use std::io;
|
||||
use crate::commands::status::{State, LocalObj};
|
||||
|
||||
@@ -4,11 +4,10 @@ use std::io::Write;
|
||||
use std::fs::OpenOptions;
|
||||
use std::path::PathBuf;
|
||||
use std::time::SystemTime;
|
||||
use crate::commands::status::{State};
|
||||
use crate::commands::status::State;
|
||||
use crate::utils::into::IntoPathBuf;
|
||||
use crate::utils::{path, read};
|
||||
use crate::store::head;
|
||||
use crate::store::object::{update_dates, add_node, rm_node};
|
||||
use crate::store::object::update_dates;
|
||||
|
||||
use crate::store::object::object::ObjMethods;
|
||||
use crate::store::object::object::Obj;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use crate::utils::into::IntoPathBuf;
|
||||
use crate::store::object::object::Obj;
|
||||
use std::path::PathBuf;
|
||||
use crate::store::object::update_dates;
|
||||
use crate::store::object::object::ObjMethods;
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io::{self, BufRead, BufReader, Write, Lines};
|
||||
use std::io::{self, BufRead, BufReader, Write};
|
||||
|
||||
pub struct Tree {
|
||||
pub obj: Obj,
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
use clap::{App, Arg, SubCommand, ArgMatches};
|
||||
use textwrap::{fill, Options};
|
||||
// use textwrap::{fill, Options};
|
||||
|
||||
use crate::commands::clone::{self, CloneArgs};
|
||||
use crate::commands::clone::CloneArgs;
|
||||
use crate::global;
|
||||
use crate::commands;
|
||||
|
||||
fn sized_str<'a>(content: &'a str) -> &'a str {
|
||||
fill(content, Options::new(70).width).as_str();
|
||||
"ok"
|
||||
}
|
||||
|
||||
fn test() -> String {
|
||||
String::from("ok")
|
||||
}
|
||||
// fn sized_str<'a>(content: &'a str) -> &'a str {
|
||||
// fill(content, Options::new(70).width).as_str();
|
||||
// "ok"
|
||||
// }
|
||||
|
||||
pub fn create() -> App<'static, 'static> {
|
||||
let remote_desc = sized_str(&format!("The repository to clone from. See the NEXTSYNC URLS section below for more information on specifying repositories."));
|
||||
let depth_desc = sized_str(&format!("Depth of the recursive fetch of object properties. This value should be lower when there are a lot of files per directory and higher when there are a lot of subdirectories with fewer files. (Default: {})", clone::DEPTH));
|
||||
// let remote_desc = sized_str(&format!("The repository to clone from. See the NEXTSYNC URLS section below for more information on specifying repositories."));
|
||||
// let depth_desc = sized_str(&format!("Depth of the recursive fetch of object properties. This value should be lower when there are a lot of files per directory and higher when there are a lot of subdirectories with fewer files. (Default: {})", clone::DEPTH));
|
||||
SubCommand::with_name("clone")
|
||||
.arg(
|
||||
Arg::with_name("remote")
|
||||
|
||||
Reference in New Issue
Block a user