Skip to content

Commit

Permalink
use . along with to select by name
Browse files Browse the repository at this point in the history
  • Loading branch information
zahash committed Oct 12, 2023
1 parent 4736386 commit ad048cd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "royalguard"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
authors = ["Zahash <[email protected]>"]
description = "Ergonomic Command Line Password Manager. Forever Free."
Expand Down
11 changes: 8 additions & 3 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'text> Cond<'text> for Filter<'text> {
impl<'text> Cond<'text> for Contains<'text> {
fn test(&self, data: &Data) -> bool {
match self.attr {
"$name" => data.name.contains(self.substr),
"$name" | "." => data.name.contains(self.substr),
attr => data
.fields
.get(attr)
Expand All @@ -201,7 +201,7 @@ impl<'text> Cond<'text> for Contains<'text> {
impl<'text> Cond<'text> for Matches<'text> {
fn test(&self, data: &Data) -> bool {
match self.attr {
"$name" => self.pat.find(&data.name).is_some(),
"$name" | "." => self.pat.find(&data.name).is_some(),
attr => data
.fields
.get(attr)
Expand All @@ -214,7 +214,7 @@ impl<'text> Cond<'text> for Matches<'text> {
impl<'text> Cond<'text> for Is<'text> {
fn test(&self, data: &Data) -> bool {
match self.attr {
"$name" => data.name == self.value,
"$name" | "." => data.name == self.value,
attr => data.fields.get(attr).map_or(false, |val| val == self.value),
}
}
Expand Down Expand Up @@ -398,6 +398,11 @@ mod tests {
"show $name is sus",
["'sus' name='potatus' user='sussolini'"]
);
check!(
&mut state,
"show . is sus",
["'sus' name='potatus' user='sussolini'"]
);
check!(
&mut state,
"show name is potatus",
Expand Down
19 changes: 13 additions & 6 deletions src/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ const LOGO: &'static str = r#"
"#;

const HELP: &'static str = r#"
set gmail user = sussolini pass = 'use single quote for spaces' url = mail.google.sus
set gmail pass = updatedpassword
del gmail
show all
show gmail
show user is sussolini and (pass contains sus or url matches '.*com')
Add, Update and Delete:
set gmail user = sussolini pass = 'use single quote for spaces' url = mail.google.sus
set gmail pass = updatedpassword
del gmail
Show:
show all
show gmail
show user is sussolini and (pass contains sus or url matches '.*com')
Show (filter by name):
show $name contains mail
show . contains mail
"#;

/// Royal Guard
Expand Down

0 comments on commit ad048cd

Please sign in to comment.