Comments (11)
Yep, my process definitely started with "I'll just send a pull request" and quickly turned into "this is nontrivial and should be a feature request".
from gmailctl.
This is not easy to do, because the diff is done at the lowest level of filters, where all the fields are simple strings. This allows for easy comparison with whatever is currently set in Gmail, without having to parse and back-translate upstream filters to higher level representations.
The line you report (to: {[email protected] .... }
) is effectively just a string, so the cmp
package would report the same result.
from gmailctl.
Is there a reasonable place to say "here are all the filters before, here are all the filters after, throw it at cmp.Diff
and see how bad it looks"? Should serve as a reasonable starting point.
from gmailctl.
Alright, I found a place and ran it, lutzky@f3264ab. The output doesn't look great.
from gmailctl.
Yeah indeed. It's a bunch of strings not very different from what's existing. To make it better you really need a parser for Gmail filter expressions.
from gmailctl.
Yep. Now, even if I were to write such a parser, the output for cmp.Diff
on imagined parsed filters doesn't look great:
main.FilterNode{
And: []main.FilterNode{
{
And: nil,
Or: []main.FilterNode{
{From: "person1"},
{From: "person2"},
- {From: "person3"},
{From: "person4"},
},
Not: nil,
From: "",
},
{
And: nil,
Or: nil,
Not: &main.FilterNode{
And: nil,
Or: []main.FilterNode{
{From: "person5"},
{
And: nil,
Or: nil,
Not: nil,
- From: "person6",
+ From: "person7",
},
},
Not: nil,
From: "",
},
From: "",
},
},
Or: nil,
Not: nil,
From: "",
}
Even if we hide all the nil
and ""
entries, what we actually want is more like this:
before: {person1 person2 person3 person4} -{person5 person6}
after: {person1 person2 person4} -{person5 person7}
diff:
{
person1
person2
- person3
person4
}
-{
person5
- person6
+ person7
}
So, essentially, it's a matter of adding newlines and indentation in a few places, and running a traditional diff. I'll see if I can mock something up.
from gmailctl.
It's quick-and-dirty, but perhaps not entirely useless: https://go.dev/play/p/EREXFY8gTwR
from gmailctl.
It's certainly a start. There are a lot more cases to consider though. From the top of my head:
- quotes:
from:"foo bar"
- parenthesis:
(a b) subject:(foo bar)
- nested expressions:
-(x {y -z} k)
And combinations of those.
from gmailctl.
This issue is stale because it has been open for 30 days without activity.
This will be closed in 7 days, unless you add the 'lifecycle/keep-alive' label or comment.
from gmailctl.
Tweaked it a bit to handle your example cases: https://go.dev/play/p/qNFzmtFEWCo
WDYT?
from gmailctl.
Cool! I tried a couple more nasty cases (colons outside operators) and the results still seem good! https://go.dev/play/p/LtIy47e5eY7.
from gmailctl.
Related Issues (20)
- Tests fail with realistic inputs HOT 2
- Cant figure it out HOT 1
- Option for `gmailctl download` to "download" a local XML file HOT 2
- Add option to apply all parent labels if `gmailctl` is managing labels HOT 4
- `gmailctl` should interpret `Some/Label/Name` as a nested label HOT 3
- Consider editing repository setings to remove "Packages" section HOT 1
- Progress indicators HOT 4
- Token has been expired or revoked HOT 6
- Following flow for sorting mails possible? HOT 3
- Potential GMail bug causes exporting to XML not working with category action rules, workaround needed HOT 2
- Support diffing with colordiff/delta/etc HOT 4
- Why does gmailctl split this kind of "or" filter into separate rules? HOT 19
- Support `deliveredto` rule HOT 3
- Could libsonnet helper files be situated next to the tmp file for `gmailctl edit` to avoid import path errors? HOT 4
- Is it possible to programatically edit filters with gmailctl? HOT 2
- Expose a public API HOT 2
- automatic quoting of addresses with plus sign should not quote addresses that are already quoted HOT 2
- Dependency Dashboard
- Requires Go v1.19 but README says v1.17
- Feature request: Display URL to test the new rules HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gmailctl.