From 05c418e00a6f19edc80b00d10265b36e0a82aef5 Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:33:22 +1000 Subject: [PATCH 1/3] global config file picker expected yaml --- cmd/slackdump/internal/ui/cfgui/configuration.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/slackdump/internal/ui/cfgui/configuration.go b/cmd/slackdump/internal/ui/cfgui/configuration.go index 787c9419..0e9388ef 100644 --- a/cmd/slackdump/internal/ui/cfgui/configuration.go +++ b/cmd/slackdump/internal/ui/cfgui/configuration.go @@ -9,6 +9,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/rusq/rbubbles/filemgr" + "github.com/rusq/slackdump/v3/cmd/slackdump/internal/apiconfig" "github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg" "github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/updaters" @@ -81,7 +82,7 @@ func globalConfig() Configuration { Description: "API limits file", Updater: updaters.NewFilepickModel( &cfg.ConfigFile, - filemgr.New(os.DirFS("."), ".", 15, "*.yaml", "*.yml"), + filemgr.New(os.DirFS("."), ".", 15, "*.toml", "*.tml"), validateAPIconfig, ), }, From 8d92f24ab37d370db061540f345e40d2811487f3 Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Sat, 4 Jan 2025 14:11:16 +1000 Subject: [PATCH 2/3] clarify syntax --- cmd/slackdump/internal/man/assets/syntax.md | 75 +++++++++++++++------ 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/cmd/slackdump/internal/man/assets/syntax.md b/cmd/slackdump/internal/man/assets/syntax.md index e5c2ad3b..e3822355 100644 --- a/cmd/slackdump/internal/man/assets/syntax.md +++ b/cmd/slackdump/internal/man/assets/syntax.md @@ -5,17 +5,35 @@ you to include or exclude specific channels from an operation. This document explains the inclusive and exclusive modes, their syntax, and provides examples for practical use. +## Executive Summary + +- Entities are separated by spaces on the CLI, and by new lines in files. +- __FILES__: Use the `@` prefix for files, example: `@channels.txt`. + - each line in the file should contain a channel or thread ID or URL of a + channel or thread, or a comment if the line starts with `#`. + - it supports the same syntax as the command line for time ranges and + exclusion. +- __EXCLUSION__: Use the `^` prefix for exclusions, example: `^C123`. +- __TIME RANGE__: Time range parameters are optional but can refine your export + or archive operation. + - Time ranges are specified as `time_from` and `time_to` in + `YYYY-MM-DDTHH:MM:SS` format. + - They should be separated by commas without spaces. + ## Syntax Slackdump accepts channel IDs or URLs as arguments, separated by -spaces. The **channel ID** is the last part of the channel URL. -For example, in the URL: +spaces, if specified on the command line, and by new line characters, +if supplied in a file. URLs and IDs can be used interchangeably: + +Here's the Slack Channel URL, where the **channel ID** is the last part of the +URL: ``` -https://xxx.slack.com/archives/C12345678 +https://xxx.slack.com/archives/C051D4052 ``` -the channel ID is `C12345678`. +the channel ID is `C051D4052`. To get a list of all available channel IDs, run: ```bash @@ -27,14 +45,16 @@ The syntax for specifying entities is as follows: [[prefix]term[,[time_from],[time_to]]|@file] ``` -Please note that there are no spaces before or after the commas -",". +Please note that there are no spaces before or after the commas ",". Where: - `prefix`: Determines how the channel is processed. - No prefix: Include the channel in the operation. - `^`: Exclude the channel from the operation. -- `term`: The channel ID, URL, or filename. +- `term`: can be one of the following: + - Channel ID (i.e. C051D4052) + - Thread ID i.e. "C051D4052:1665917454.731419", + - URL of the channel or thread(see above) - `time_from` and `time_to`: Optional parameters specifying the time range for the operation in `YYYY-MM-DDTHH:MM:SS` format. - If only `time_from` is specified, the operation includes all messages @@ -43,12 +63,14 @@ Where: that time. - If both are specified, the operation includes messages within that time range. -- `@file`: A file containing channel IDs or URLs, with each entry on a new - line. +- `@file`: A file containing channel or thread IDs or URLs: + - each entry on a new line; + - comments start with `#`, and should be on a new line; + - empty lines are skipped. ## Examples -### 1. Exporting Specific Channels +### 1. Exporting Specific Channels or Threads To include only specific channels in the operation: @@ -58,7 +80,17 @@ slackdump export C12401724 https://xxx.slack.com/archives/C4812934 This command exports **only** channels `C12401724` and `C4812934`. -### 2. Exclude Specific Channels +To include specific threads you can provide the thread URL: +```bash +slackdump dump \ + https://ora600.slack.com/archives/C051D4052/p1665917454731419 +``` +or use the Slackdump thread notation: +```bash +slackdump export C051D4052:1665917454.731419 +``` + +### 2. Exclude Specific Channels or Threads To exclude one or more channels, prefix them with ^. For example, to export everything except channel C123456: @@ -70,8 +102,8 @@ This excludes `C123456` while exporting the rest. ### 3. Using a File for Channel Lists -You can specify a file containing channel IDs or URLs. To include -channels from a file: +You can specify a file containing channel IDs or URLs. The file should contain +IDs, one per line. To include channels from a file: ```bash slackdump archive @data.txt @@ -84,6 +116,14 @@ slackdump archive @data.txt ^C123456 ``` This command includes channels listed in data.txt but excludes C123456. +Sample file: +```text +# This is a comment +C123456 +^C123457 +https://ora600.slack.com/archives/C051D4052/p1665917454731419 +``` + ### 4. Using Time Ranges To include messages from a specific time range: @@ -109,12 +149,3 @@ After some date: slackdump archive C123456,,2022-01-31T23:59:59 ``` -## TL;DR - -- Use the `@` prefix for files and the `^` prefix for exclusions. -- Time range parameters are optional but can refine your export or - archive operation. - - Time ranges are specified as `time_from` and `time_to` in - `YYYY-MM-DDTHH:MM:SS` format. - - They should be separated by commas without spaces. - From ffef55535dd74794c3d2af8846c9090727a0e1b2 Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Sat, 4 Jan 2025 14:55:54 +1000 Subject: [PATCH 3/3] define apiconfig exts globally --- cmd/slackdump/internal/apiconfig/apiconfig.go | 4 +++- cmd/slackdump/internal/apiconfig/check.go | 2 +- cmd/slackdump/internal/ui/cfgui/configuration.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/slackdump/internal/apiconfig/apiconfig.go b/cmd/slackdump/internal/apiconfig/apiconfig.go index 9cfd1821..48a42423 100644 --- a/cmd/slackdump/internal/apiconfig/apiconfig.go +++ b/cmd/slackdump/internal/apiconfig/apiconfig.go @@ -29,6 +29,8 @@ configuration file. }, } +var ConfigExts = []string{"*.toml", "*.tml"} + var ErrConfigInvalid = errors.New("config validation failed") // Load reads, parses and validates the config file. @@ -83,7 +85,7 @@ func printErrors(w io.Writer, err error) error { } var wErr error - var printErr = func(format string, a ...any) { + printErr := func(format string, a ...any) { if wErr != nil { return } diff --git a/cmd/slackdump/internal/apiconfig/check.go b/cmd/slackdump/internal/apiconfig/check.go index c8f6fefb..d3bafa54 100644 --- a/cmd/slackdump/internal/apiconfig/check.go +++ b/cmd/slackdump/internal/apiconfig/check.go @@ -57,7 +57,7 @@ func CheckFile(filename string) error { } func wizConfigCheck(ctx context.Context, cmd *base.Command, args []string) error { - f := filemgr.New(os.DirFS("."), ".", 15, "*.toml", "*.tml") + f := filemgr.New(os.DirFS("."), ".", 15, ConfigExts...) f.Focus() f.ShowHelp = true f.Style = filemgr.Style{ diff --git a/cmd/slackdump/internal/ui/cfgui/configuration.go b/cmd/slackdump/internal/ui/cfgui/configuration.go index 0e9388ef..38cf0163 100644 --- a/cmd/slackdump/internal/ui/cfgui/configuration.go +++ b/cmd/slackdump/internal/ui/cfgui/configuration.go @@ -82,7 +82,7 @@ func globalConfig() Configuration { Description: "API limits file", Updater: updaters.NewFilepickModel( &cfg.ConfigFile, - filemgr.New(os.DirFS("."), ".", 15, "*.toml", "*.tml"), + filemgr.New(os.DirFS("."), ".", 15, apiconfig.ConfigExts...), validateAPIconfig, ), },