~rockorager/offmap

offmap: offmap: add -a, --account flag v2 SUPERSEDED

Tim Culverhouse: 1
 offmap: add -a, --account flag

 4 files changed, 38 insertions(+), 0 deletions(-)
#899397 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rockorager/offmap/patches/37373/mbox | git am -3
Learn more about email & git

[PATCH offmap v2] offmap: add -a, --account flag Export this patch

Add a flag to sync the specified account

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
---
v2: use a string slice to allow specifying multiple accounts, update docs

 cmd/diff.go      |  9 +++++++++
 cmd/offmap.go    | 10 ++++++++++
 cmd/sync.go      |  9 +++++++++
 doc/offmap.1.scd | 10 ++++++++++
 4 files changed, 38 insertions(+)

diff --git a/cmd/diff.go b/cmd/diff.go
index 6855bf40083a..21ee6b60d2c9 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().StringSliceP("account", "a", nil, "only sync the specified account(s)")
	return cmd
}

@@ -26,7 +27,15 @@ func diff(cmd *cobra.Command, args []string) {
	if err != nil {
		log.Fatalf("could not read config: %v", err)
	}
	accts, err := cmd.Flags().GetStringSlice("account")
	if err != nil {
		log.Errorf("offmap: could not parse account: %v", err)
		return
	}
	for _, cfg := range cfgs {
		if accts != nil && notContains(cfg.Name, accts) {
			continue
		}
		start := time.Now()

		// Bootstrap the app
diff --git a/cmd/offmap.go b/cmd/offmap.go
index 94d05b866c4a..a2715a645703 100644
--- a/cmd/offmap.go
+++ b/cmd/offmap.go
@@ -31,3 +31,13 @@ func main() {
		log.Fatalf("%v", err)
	}
}

// returns true if the target is not contained in the slice
func notContains(target string, items []string) bool {
	for _, item := range items {
		if item == target {
			return false
		}
	}
	return true
}
diff --git a/cmd/sync.go b/cmd/sync.go
index de6782dcc285..ff7bc9660f83 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().StringSliceP("account", "a", nil, "only sync the specified account(s)")
	return cmd
}

@@ -26,7 +27,15 @@ func sync(cmd *cobra.Command, args []string) {
	if err != nil {
		log.Debugf("%v", err)
	}
	accts, err := cmd.Flags().GetStringSlice("account")
	if err != nil {
		log.Errorf("offmap: could not parse account: %v", err)
		return
	}
	for _, cfg := range cfgs {
		if accts != nil && notContains(cfg.Name, accts) {
			continue
		}
		log.Infof("offmap: syncing account %s", cfg.Name)
		start := time.Now()

diff --git a/doc/offmap.1.scd b/doc/offmap.1.scd
index a35462753d66..bdfcee241a23 100644
--- a/doc/offmap.1.scd
+++ b/doc/offmap.1.scd
@@ -17,6 +17,16 @@ offmap - an email synchronizer

# OPTIONS

*-a, --account* <name[,name]>
	Only sync the specified account(s). Can be passed more than one time to
	specify multiple accounts, or a comma separated list can be used:

	Example:
	```
	offmap sync -a personal,work
	offmap sync -a personal -a work
	```

*-v, --verbose*
	Increase verbosity level. Can be used multiple times

-- 
2.38.1
offmap/patches/.build.yml: SUCCESS in 1m53s

[offmap: add -a, --account flag][0] v2 from [Tim Culverhouse][1]

[0]: https://lists.sr.ht/~rockorager/offmap/patches/37373
[1]: mailto:tim@timculverhouse.com

✓ #899397 SUCCESS offmap/patches/.build.yml https://builds.sr.ht/~rockorager/job/899397
I think a more efficient way would be to delete() all map entries
matching accs.