[PATCH offmap] offmap: add -a, --account flag
Export this patch
Add a flag to sync the specified account
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
---
cmd/diff.go | 9 +++++++++
cmd/sync.go | 9 +++++++++
2 files changed, 18 insertions(+)
diff --git a/cmd/diff.go b/cmd/diff.go
index 6855bf4..d0844f6 100644
--- a/cmd/diff.go
+++ b/cmd/diff.go
@@ -16,6 +16,7 @@ func newDiffCommand() *cobra.Command {
Short: "diff enumerates changes from last sync for a mailstore",
Run: diff,
}
+ cmd.Flags().StringP("account", "a", "", "only diff the specified account")
return cmd
}
@@ -26,7 +27,15 @@ func diff(cmd *cobra.Command, args []string) {
if err != nil {
log.Fatalf("could not read config: %v", err)
}
+ acct, err := cmd.Flags().GetString("account")
+ if err != nil {
+ log.Errorf("offmap: could not parse account: %v", err)
+ return
+ }
for _, cfg := range cfgs {
I think it would be easy to just right away implement support for
multiple accounts by either specifying -a multiple times, or splitting
by `,`. What do you think?
so: -a Personal,Work
is converted to map[string]bool{"Personal":true,"Work": true}
Good idea!
cobra supports two of these out of the box, i think StringSlice is what we want:
It can support both of these:
`offmap sync -a personal -a work`
`offmap sync -a personal,work`
I'll send a v2
--
Tim
+ if acct != "" && acct != cfg.Name {
+ continue
+ }
start := time.Now()
// Bootstrap the app
diff --git a/cmd/sync.go b/cmd/sync.go
index de6782d..4dcd6a2 100644
--- a/cmd/sync.go
+++ b/cmd/sync.go
@@ -16,6 +16,7 @@ func newSyncCommand() *cobra.Command {
Short: "sync synchronizes mail stores",
Run: sync,
}
+ cmd.Flags().StringP("account", "a", "", "only sync the specified account")
return cmd
}
@@ -26,7 +27,15 @@ func sync(cmd *cobra.Command, args []string) {
if err != nil {
log.Debugf("%v", err)
}
+ acct, err := cmd.Flags().GetString("account")
+ if err != nil {
+ log.Errorf("offmap: could not parse account: %v", err)
+ return
+ }
for _, cfg := range cfgs {
+ if acct != "" && acct != cfg.Name {
+ continue
+ }
Same as above. :)
log.Infof("offmap: syncing account %s", cfg.Name)
start := time.Now()
--
2.38.1
offmap/patches/.build.yml: SUCCESS in 1m54s
[offmap: add -a, --account flag][0] from [Tim Culverhouse][1]
[0]: https://lists.sr.ht/~rockorager/offmap/patches/37361
[1]: mailto:tim@timculverhouse.com
✓ #899031 SUCCESS offmap/patches/.build.yml https://builds.sr.ht/~rockorager/job/899031