Skip to content

Commit

Permalink
add more doc
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Dec 21, 2024
1 parent bc96f08 commit 76fddd5
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 56 deletions.
4 changes: 3 additions & 1 deletion cmd/slackdump/internal/diag/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var cmdEdge = &base.Command{
# Slack Edge API test tool
Edge test attempts to call the Edge API with the provided credentials.
Not particularly useful for end users, but can be used to test the Edge API.
`,
}

Expand Down Expand Up @@ -62,7 +64,7 @@ func runEdge(ctx context.Context, cmd *base.Command, args []string) error {
lg.Info("*** AdminEmojiList test ***")
var allEmoji edge.EmojiResult

var iter = 0
iter := 0
for res, err := range cl.AdminEmojiList(ctx) {
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions cmd/slackdump/internal/diag/wizdebug.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/huh"

"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/bubbles/menu"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/cfgui"
Expand All @@ -15,6 +16,7 @@ var cmdWizDebug = &base.Command{
Short: "run the wizard debug command",
Run: runWizDebug,
PrintFlags: true,
HideWizard: true,
}

type wdWhat int
Expand Down
13 changes: 8 additions & 5 deletions cmd/slackdump/internal/export/assets/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ By default, it exports the entire workspace that your user can access.
You can customize the archive to include specific channels, groups, or
direct messages by providing their URLs or IDs.

The ZIP file it generates is compatible with the Slack Export format with Slackdump specific extensions.
The ZIP file it generates is compatible with the Slack Export format with
Slackdump specific extensions.

The export file is understood by Slack Import feature with the following
caveat:
Expand All @@ -21,7 +22,7 @@ caveat:
/
├── __uploads : all uploaded files are placed in this dir.
│ └── F02PM6A1AUA : slack file ID is used as a directory name
| └── Chevy.jpg : file attachment
└── Chevy.jpg : file attachment
├── everyone : channel "#everyone"
│ ├── 2022-01-01.json : all messages for the 1 Jan 2022.
│ └── 2022-01-04.json : " " " " 4 Jan 2022.
Expand All @@ -36,11 +37,13 @@ caveat:
### Channels
The channels are be saved in directories, named after the channel title,
i.e. `#random` would be saved to "random" directory. The directory will
contain a set of JSON files, one per each day.
contain a set of JSON files, one per each day. If there were no
conversations on some particular day, there will be no JSON file for that
day.

### Users
User directories will have an "D" prefix, to find out the user name,
check `users.json` file.
User directories will have a "D" prefix, to find out the user name, check
`users.json` file.

### Group Messages
Group messages will have all involved user handles in their name.
Expand Down
15 changes: 8 additions & 7 deletions cmd/slackdump/internal/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package export

import (
"context"
_ "embed"
"errors"
"fmt"
"strings"
Expand All @@ -23,23 +24,23 @@ var CmdExport = &base.Command{
UsageLine: "slackdump export",
Short: "exports the Slack Workspace or individual conversations",
FlagMask: cfg.OmitUserCacheFlag,
Long: ``, // TODO: add long description
Long: mdExport, // TODO: add long description
CustomFlags: false,
PrintFlags: true,
RequireAuth: true,
}

//go:embed assets/export.md
var mdExport string

type exportFlags struct {
ExportStorageType fileproc.StorageType
ExportToken string
}

var (
compat bool
options = exportFlags{
ExportStorageType: fileproc.STmattermost,
}
)
var options = exportFlags{
ExportStorageType: fileproc.STmattermost,
}

func init() {
CmdExport.Flag.Var(&options.ExportStorageType, "type", "export file storage type")
Expand Down
98 changes: 65 additions & 33 deletions cmd/slackdump/internal/man/assets/syntax.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,100 @@
# Slackdump Channel List Syntax

Slackdump major modes like `archive`, `export` and `dump` support
including or excluding channels from the operation. This document
describes how to use the inclusive and exclusive modes, along with
examples.
Slackdump major commands like `archive`, `export`, and `dump` allow 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.

Slackdump accepts channel IDs or URLs as arguments separated by space.
The channel ID is the last part of the channel URL. For example, in the
URL
## 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:

```
https://xxx.slack.com/archives/C12345678
```

the channel ID is `C12345678`.

You can also get all available channel IDs by running the `slackdump list channels` command.

## Syntax

- No prefix: include the channel in the operation.
- `^`: exclude the channel from the operation.
- `@`: read the channels from a file.
To get a list of all available channel IDs, run:
```bash
slackdump list channels
```

File can contain one or more channel IDs or URLs, one per line.
The syntax for specifying entities is as follows:
```
[[prefix]term[/[time_from]/[time_to]]|@file]
```

Below, we'll look at some examples.
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.
- `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
starting from that time.
- If only `time_to` is specified, the operation includes all messages
up to that time.
- If both are specified, the operation includes messages within that
time range.

A file can contain one or more channel IDs or URLs, with each entry on a
new line.

## Examples

### Exporting Only Channels You Need
### 1. Exporting Specific Channels

To include only those channels you're interested in, use the following
syntax:
To include only specific channels in the operation:

```bash
slackdump export C12401724 https://xxx.slack.com/archives/C4812934
```

The command above will export ONLY channels `C12401724` and `C4812934`.
This command exports **only** channels `C12401724` and `C4812934`.

### Exporting Everything Except Some Unwanted Channels
### 2. Exclude Specific Channels

To exclude one or more channels from the export, prefix the channel with
the caret "^" character. For example, you want to export everything
except channel `C123456`:
To exclude one or more channels, prefix them with ^. For example, to
export everything except channel C123456:

```bash
slackdump -export my-workspace.zip ^C123456
slackdump export ^C123456
```
This excludes `C123456` while exporting the rest.

### 3. Using a File for Channel Lists

### Providing the List in a File
You can specify a file containing channel IDs or URLs. To include
channels from a file:

You can specify the filename instead of listing all the channels on the
command line. To include the channels from the file, use the "@"
character prefix. The following example shows how to load the channels
from the file named "data.txt":
```bash
slackdump archive @data.txt
```
It is also possible to combine files and channels, i.e.:
You can also combine files and individual channel exclusions. For
example:

```bash
slackdump archive @data.txt ^C123456
```
The command above will read the channels from data.txt and exclude the
channel `C123456` from the Export.
This command includes channels listed in data.txt but excludes C123456.

### 4. Using Time Ranges

To include messages from a specific time range:

```bash
slackdump archive C123456/2022-01-01T00:00:00/2022-01-31T23:59:59
```

This command archives messages from channel `C123456` between January 1st
and January 31st, 2022.

## 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.

34 changes: 34 additions & 0 deletions cmd/slackdump/internal/view/assets/view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Command: view

The `view` command allows you to view the contents of an archive,
export, or dump directory or ZIP file.

It is a read-only command that does not modify the contents of the
specified directory or file.

Viewer supports displaying downloaded images, videos as well as remote
content.

## Usage

```bash
slackdump view <directory_or_file>
```

If you experience problems viewing, run the viewer with DEBUG mode
enabled, and report the violating message to the Github Issues page.

```bash
DEBUG=1 slackdump view <directory_or_file>
```

It is recommended that you remove all sensitive information from the
JSON before sharing it, and also, to encrypt your message, you can use
the `slackdump tools encrypt` command, for example:

```bash
cat your_message.txt | slackdump tools encrypt > encrypted_message.txt
```

This will encrypt it using the embedded GPG public key, and can only be
encrypted by the author.
13 changes: 8 additions & 5 deletions cmd/slackdump/internal/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package view
import (
"archive/zip"
"context"
_ "embed"
"errors"
"fmt"
"io"
Expand All @@ -13,19 +14,21 @@ import (
"strings"

br "github.com/pkg/browser"

"github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
"github.com/rusq/slackdump/v3/internal/chunk"
"github.com/rusq/slackdump/v3/internal/viewer"
"github.com/rusq/slackdump/v3/internal/viewer/source"
)

//go:embed assets/view.md
var mdView string

var CmdView = &base.Command{
Short: "View the slackdump files",
UsageLine: "slackdump view [flags]",
Long: `
View the slackdump files.
`,
Short: "View the slackdump files",
UsageLine: "slackdump view [flags]",
Long: mdView,
PrintFlags: true,
FlagMask: cfg.OmitAll,
Run: RunView,
Expand Down
10 changes: 5 additions & 5 deletions internal/structures/entity_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (
)

const (
// excludePrefix is the prefix that is used to mark channel exclusions, i.e.
// for export or when downloading conversations.
// excludePrefix is the prefix that is used to mark channel
// exclusions, i.e. for export or when downloading conversations.
excludePrefix = "^"
filePrefix = "@"
timeSeparator = "|"
timeSeparator = "/"
timeFmt = "2006-01-02T15:04:05"

// maxFileEntries is the maximum non-empty entries that will be read from
// the file.
// maxFileEntries is the maximum non-empty entries that will be read
// from the file.
maxFileEntries = 1048576
)

Expand Down

0 comments on commit 76fddd5

Please sign in to comment.