fix: Resolve filter parsing and default directory errors
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
@@ -395,6 +395,15 @@ impl Settings {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_dir() -> anyhow::Result<PathBuf> {
|
||||
let mut path = dirs::home_dir()
|
||||
.ok_or_else(|| anyhow::anyhow!("No home directory found"))?;
|
||||
path.push(".keep");
|
||||
if !path.exists() {
|
||||
std::fs::create_dir_all(&path)?;
|
||||
}
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
/// Get server password from password_file or directly from config if configured
|
||||
pub fn get_server_password(&self) -> Result<Option<String>> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
WHITESPACE = _{ " " | "\t" | "\n" | "\r" }
|
||||
|
||||
//! This Pest grammar defines the syntax for filter chains used in the Keep application.
|
||||
#! This Pest grammar defines the syntax for filter chains used in the Keep application.
|
||||
|
||||
// Main entry point for parsing multiple filters separated by pipes
|
||||
filters = { SOI ~ filter ~ (pipe ~ filter)* ~ EOI }
|
||||
|
||||
@@ -14,30 +14,30 @@ pub struct Filter {
|
||||
|
||||
pub fn parse_filter_string(input: &str) -> Result<Vec<Filter>, Box<dyn std::error::Error>> {
|
||||
let mut filters = Vec::new();
|
||||
let pairs = FilterParser::parse(FilterParser::Rule::filters, input)?;
|
||||
let pairs = FilterParser::parse(Rule::filters, input)?;
|
||||
|
||||
for pair in pairs {
|
||||
if pair.as_rule() == FilterParser::Rule::filter {
|
||||
if pair.as_rule() == Rule::filter {
|
||||
let mut name = String::new();
|
||||
let mut options = HashMap::new();
|
||||
|
||||
for inner_pair in pair.into_inner() {
|
||||
match inner_pair.as_rule() {
|
||||
FilterParser::Rule::filter_name => {
|
||||
Rule::filter_name => {
|
||||
name = inner_pair.as_str().to_string();
|
||||
}
|
||||
FilterParser::Rule::options => {
|
||||
Rule::options => {
|
||||
for option_pair in inner_pair.into_inner() {
|
||||
if option_pair.as_rule() == FilterParser::Rule::option {
|
||||
if option_pair.as_rule() == Rule::option {
|
||||
let mut option_name = None;
|
||||
let mut option_value = None;
|
||||
|
||||
for option_inner in option_pair.into_inner() {
|
||||
match option_inner.as_rule() {
|
||||
FilterParser::Rule::option_name => {
|
||||
Rule::option_name => {
|
||||
option_name = Some(option_inner.as_str().to_string());
|
||||
}
|
||||
FilterParser::Rule::option_value => {
|
||||
Rule::option_value => {
|
||||
option_value = Some(parse_option_value(option_inner.as_str())?);
|
||||
}
|
||||
_ => {}
|
||||
|
||||
Reference in New Issue
Block a user