Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev (0.2.0) #1

Draft
wants to merge 40 commits into
base: release
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
36f721b
started working on next version
noxware Sep 9, 2023
4a79528
dev notes
noxware Sep 9, 2023
1427c33
almost complete right side labels support
noxware Sep 9, 2023
62efd70
right side labels with tests passing
noxware Sep 9, 2023
62d2804
added more tests to right side labels
noxware Sep 9, 2023
94a5aaa
fcwalk now sends the config
noxware Sep 11, 2023
ac26313
basic ipc helper
noxware Sep 11, 2023
c35e079
read_messages input helper
noxware Sep 11, 2023
e9af810
renamed path message to line
noxware Sep 11, 2023
ec151b7
panic at pending important tests
noxware Sep 11, 2023
db1ced9
replaced read_documents test with read_messages
noxware Sep 13, 2023
abc453b
ignore blank lines on read_messages
noxware Sep 13, 2023
6ed7fbe
added line and document tests to read_messages
noxware Sep 13, 2023
bd8dd4a
full read_messages test
noxware Sep 13, 2023
080518a
remove method that will not be used
noxware Sep 13, 2023
4182eba
lazy but enough ipc tests
noxware Sep 13, 2023
4f3bc05
improved ipc testing
noxware Sep 13, 2023
97e8066
re-added read_stdin_documents temporarily
noxware Sep 13, 2023
252d0ad
fcq now uses labels provided by fcwalk
noxware Sep 17, 2023
823d391
fcwalk will not crash when no config folder
noxware Sep 17, 2023
4820aee
fclabels now uses labels provided by fcwalk
noxware Sep 17, 2023
f484ac1
allow explicit dir for fclink
noxware Sep 17, 2023
0e1e240
support check by having known labels
noxware Sep 18, 2023
98f00cc
refactored check tests
noxware Sep 18, 2023
f6a6925
refactored check tests further
noxware Sep 18, 2023
8ec3cb1
check system (un)known test
noxware Sep 18, 2023
52de930
fcwalk --no-config and clap dependency added
noxware Sep 26, 2023
4ccb70c
fclabels toml format and fcwalk flexibility
noxware Sep 27, 2023
0e0f7ea
removed version cli options
noxware Sep 27, 2023
141ddec
fcwalk -> fcload
noxware Sep 27, 2023
6c9d2b2
fclabels query opt
noxware Sep 27, 2023
3838777
validations and better error handling
noxware Sep 28, 2023
115c471
fclink takes explicit target folder
noxware Sep 28, 2023
bbe5e7b
fcload custom directory
noxware Sep 30, 2023
45c7eea
multiple label files support
noxware Oct 1, 2023
d978bea
stricter config errors
noxware Oct 1, 2023
cd2fe8b
added some tests to config load
noxware Oct 1, 2023
266d061
experimental soft links on fclink
noxware Oct 1, 2023
e34da3c
fclink supports directories
noxware Oct 1, 2023
e4da32e
wip
noxware Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fclink takes explicit target folder
  • Loading branch information
noxware committed Sep 28, 2023
commit 115c47109019c49a542bbeac7c1966ce2e00b0ad
10 changes: 1 addition & 9 deletions src/bin/fcinit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs;
use std::path::Path;

use fileclass::core::config::{LABELS_FILENAME, SETTINGS_FILENAME, STD_CONFIG_DIR};
use fileclass::core::config::{LABELS_FILENAME, STD_CONFIG_DIR};

const LABELS_CONTENT: &str = r#"[label]
description = "a label"
@@ -10,12 +10,9 @@ implies = ["implied"]

[implied]"#;

const SETTINGS_CONTENT: &str = r#"link_dir="fileclass/temp/links""#;

fn main() {
let folder_path = Path::new(STD_CONFIG_DIR);
let labels_path = folder_path.join(LABELS_FILENAME);
let settings_path = folder_path.join(SETTINGS_FILENAME);

// Create the folder if it doesn't exist
if !folder_path.exists() {
@@ -26,9 +23,4 @@ fn main() {
if !labels_path.exists() {
fs::write(labels_path, LABELS_CONTENT).expect("Failed to generate labels.toml");
}

// Generate settings.toml if it doesn't exist
if !settings_path.exists() {
fs::write(settings_path, SETTINGS_CONTENT).expect("Failed to generate settings.toml");
}
}
6 changes: 0 additions & 6 deletions src/bin/fclink.rs
Original file line number Diff line number Diff line change
@@ -7,16 +7,10 @@ use std::path::Path;
use std::process;
use std::{env, fs};

use fileclass::core::config::Config;
use fileclass::extra::input::{map_stdin_sources_to_target_folder, SourceTargetPair};

fn get_link_dir(args: &Vec<String>) -> String {
match args.len() {
1 => {
// TODO: Handle.
let config = Config::std_load().unwrap();
config.settings.link_dir
}
2 => args[1].clone(),
_ => {
eprintln!("Usage: fclink <target_dir>");
19 changes: 1 addition & 18 deletions src/core/config.rs
Original file line number Diff line number Diff line change
@@ -7,18 +7,10 @@ use super::label::LabelLibrary;

pub const STD_CONFIG_DIR: &str = "fileclass";
pub const LABELS_FILENAME: &str = "labels.toml";
pub const SETTINGS_FILENAME: &str = "settings.toml";

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
pub struct Config {
pub labels: LabelLibrary,
pub settings: Settings,
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
pub struct Settings {
// TODO: Use a default if missing and use that default in fcinit.
pub link_dir: String,
}

impl Config {
@@ -39,12 +31,7 @@ impl Config {
};
let labels = LabelLibrary::from_toml(&labels_content)?;

// These settings will be removed in the near future. So let's just unwrap.
let settings_path = Path::new(dir_path).join(SETTINGS_FILENAME);
let settings_content = fs::read_to_string(settings_path).unwrap();
let settings: Settings = toml::from_str(&settings_content).unwrap();

let config = Config { labels, settings };
let config = Config { labels };

Ok(config)
}
@@ -62,14 +49,10 @@ mod tests {
fn load_works() {
let config = Config::load("test_dir/fileclass").unwrap();
let labels = config.labels;
let settings = config.settings;

let label_name = labels.resolve("alias");
let label_description = labels.get_description("label");
assert_eq!(label_name, "label");
assert_eq!(label_description, "a label");

let link_dir = settings.link_dir;
assert_eq!(link_dir, "test_dir/fileclass/temp/links");
}
}
5 changes: 1 addition & 4 deletions src/extra/input.rs
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ pub fn map_stdin_sources_to_target_folder(
#[cfg(test)]
mod tests {
use super::*;
use crate::core::config::{Config, Settings};
use crate::core::config::Config;
use crate::core::label::{LabelLibrary, LabelSet};
use std::path::Path;

@@ -102,9 +102,6 @@ mod tests {
"#,
)
.unwrap(),
settings: Settings {
link_dir: "ld".to_string(),
},
}),
Message::Document(Document {
// TODO: Should this be trimmed by Document?
10 changes: 1 addition & 9 deletions src/extra/ipc.rs
Original file line number Diff line number Diff line change
@@ -74,10 +74,7 @@ impl Message {

#[cfg(test)]
mod tests {
use crate::core::{
config::Settings,
label::{LabelLibrary, LabelSet},
};
use crate::core::label::{LabelLibrary, LabelSet};

use super::*;

@@ -133,20 +130,15 @@ mod tests {
[implied]"#,
)
.unwrap();
let settings = Settings {
link_dir: "link_dir".to_string(),
};

let msg = Message::Config(Config {
labels: library.clone(),
settings: settings.clone(),
});
let serialized = msg.serialize();
let deserialized = Message::deserialize(&serialized);

assert_eq!(msg, deserialized);
assert_eq!(library.resolve("alias"), "label");
assert_eq!(library.resolve("implied"), "implied");
assert_eq!(settings.link_dir, "link_dir");
}
}