Skip to content

Commit

Permalink
disable useless tools
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Nov 22, 2024
1 parent 7cb3c8a commit 293bb18
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 59 deletions.
4 changes: 2 additions & 2 deletions cmd/slackdump/internal/diag/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/rusq/slackdump/v3/internal/edge"
)

var CmdEdge = &base.Command{
var cmdEdge = &base.Command{
Run: runEdge,
UsageLine: "slack tools edge",
Short: "Edge test",
Expand All @@ -29,7 +29,7 @@ var edgeParams = struct {
}{}

func init() {
CmdEdge.Flag.StringVar(&edgeParams.channel, "channel", "CHY5HUESG", "channel to get users from")
cmdEdge.Flag.StringVar(&edgeParams.channel, "channel", "CHY5HUESG", "channel to get users from")
}

func runEdge(ctx context.Context, cmd *base.Command, args []string) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/slackdump/internal/diag/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ DKOKJRTJslrewS0MeTopOa/NUI5zC1z9GsqWBAzrbUU=
-----END PGP PUBLIC KEY BLOCK-----
`

var CmdEncrypt = &base.Command{
var dmdEncrypt = &base.Command{
Run: runEncrypt,
UsageLine: "slackdump tools encrypt [flags] file",
Short: "encrypts a file to post in github issues",
Expand Down Expand Up @@ -111,8 +111,8 @@ func init() {
if err := initRecipient(); err != nil {
panic(err)
}
CmdEncrypt.Flag.BoolVar(&gArm, "a", false, "shorthand for -armor")
CmdEncrypt.Flag.BoolVar(&gArm, "armor", false, "armor the output")
dmdEncrypt.Flag.BoolVar(&gArm, "a", false, "shorthand for -armor")
dmdEncrypt.Flag.BoolVar(&gArm, "armor", false, "armor the output")
}

func initRecipient() error {
Expand Down
12 changes: 6 additions & 6 deletions cmd/slackdump/internal/diag/eztest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
)

var CmdEzTest = &base.Command{
var dmdEzTest = &base.Command{
Run: runEzLoginTest,
UsageLine: "slack tools eztest",
Short: "EZ-Login 3000 test",
Expand Down Expand Up @@ -57,13 +57,13 @@ type eztestOpts struct {
var eztestFlags eztestOpts

func init() {
CmdEzTest.Flag.Usage = func() {
dmdEzTest.Flag.Usage = func() {
fmt.Fprint(os.Stdout, "usage: slackdump tools eztest [flags]\n\nFlags:\n")
CmdEzTest.Flag.PrintDefaults()
dmdEzTest.Flag.PrintDefaults()
}
CmdEzTest.Flag.BoolVar(&eztestFlags.printCreds, "p", false, "print credentials")
CmdEzTest.Flag.BoolVar(&eztestFlags.legacy, "legacy-browser", false, "run with playwright")
CmdEzTest.Flag.StringVar(&eztestFlags.wsp, "w", "", "Slack `workspace` to login to.")
dmdEzTest.Flag.BoolVar(&eztestFlags.printCreds, "p", false, "print credentials")
dmdEzTest.Flag.BoolVar(&eztestFlags.legacy, "legacy-browser", false, "run with playwright")
dmdEzTest.Flag.StringVar(&eztestFlags.wsp, "w", "", "Slack `workspace` to login to.")
}

func runEzLoginTest(ctx context.Context, cmd *base.Command, args []string) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/slackdump/internal/diag/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
)

// CmdInfo is the information command.
var CmdInfo = &base.Command{
// dmdInfo is the information command.
var dmdInfo = &base.Command{
UsageLine: "slackdump tools info",
Short: "show information about Slackdump environment",
Run: runInfo,
Expand All @@ -29,7 +29,7 @@ var infoParams = struct {
}

func init() {
CmdInfo.Flag.BoolVar(&infoParams.auth, "auth", false, "show authentication diagnostic information")
dmdInfo.Flag.BoolVar(&infoParams.auth, "auth", false, "show authentication diagnostic information")
}

func runInfo(ctx context.Context, cmd *base.Command, args []string) error {
Expand Down
22 changes: 11 additions & 11 deletions cmd/slackdump/internal/diag/obfuscate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/rusq/slackdump/v3/internal/chunk/obfuscate"
)

// CmdObfuscate is the command to obfuscate sensitive data in a slackdump
// dmdObfuscate is the command to obfuscate sensitive data in a slackdump
// recording.
var CmdObfuscate = &base.Command{
var dmdObfuscate = &base.Command{
UsageLine: "slackdump tools obfuscate [options] [input] [output]",
Short: "obfuscate sensitive data in a slackdump recording",
Long: `
Expand All @@ -36,10 +36,10 @@ var obfparam struct {
}

func init() {
CmdObfuscate.Run = runObfuscate
dmdObfuscate.Run = runObfuscate

CmdObfuscate.Flag.BoolVar(&obfparam.overwrite, "f", false, "force overwrite")
CmdObfuscate.Flag.Int64Var(&obfparam.seed, "seed", time.Now().UnixNano(), "seed for the random number generator")
dmdObfuscate.Flag.BoolVar(&obfparam.overwrite, "f", false, "force overwrite")
dmdObfuscate.Flag.Int64Var(&obfparam.seed, "seed", time.Now().UnixNano(), "seed for the random number generator")
}

const (
Expand Down Expand Up @@ -68,15 +68,15 @@ func objtype(name string) int {
}

func runObfuscate(ctx context.Context, cmd *base.Command, args []string) error {
if err := CmdObfuscate.Flag.Parse(args); err != nil {
if err := dmdObfuscate.Flag.Parse(args); err != nil {
return err
}

if CmdObfuscate.Flag.NArg() == 2 {
obfparam.input = CmdObfuscate.Flag.Arg(0)
obfparam.output = CmdObfuscate.Flag.Arg(1)
} else if CmdObfuscate.Flag.NArg() == 1 {
obfparam.input = CmdObfuscate.Flag.Arg(0)
if dmdObfuscate.Flag.NArg() == 2 {
obfparam.input = dmdObfuscate.Flag.Arg(0)
obfparam.output = dmdObfuscate.Flag.Arg(1)
} else if dmdObfuscate.Flag.NArg() == 1 {
obfparam.input = dmdObfuscate.Flag.Arg(0)
obfparam.output = "-"
} else {
obfparam.input = "-"
Expand Down
6 changes: 3 additions & 3 deletions cmd/slackdump/internal/diag/rawoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/rusq/slackdump/v3/internal/structures"
)

var CmdRawOutput = &base.Command{
var cmdRawOutput = &base.Command{
Run: nil, // populated by init to break the init cycle
UsageLine: "slackdump tools rawoutput [flags] <id>",
Short: "record raw API output",
Expand Down Expand Up @@ -50,8 +50,8 @@ type rawOutputParams struct {
var p rawOutputParams

func init() {
CmdRawOutput.Run = runRawOutput
CmdRawOutput.Flag.StringVar(&p.output, "o", "slackdump_raw.log", "output file")
cmdRawOutput.Run = runRawOutput
cmdRawOutput.Flag.StringVar(&p.output, "o", "slackdump_raw.log", "output file")
}

func runRawOutput(ctx context.Context, cmd *base.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/slackdump/internal/diag/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/rusq/slackdump/v3/internal/chunk"
)

var CmdRecord = &base.Command{
var cmdRecord = &base.Command{
UsageLine: "slackdump tools record",
Short: "chunk record commands",
Commands: []*base.Command{cmdRecordStream, cmdRecordState},
Expand Down
16 changes: 8 additions & 8 deletions cmd/slackdump/internal/diag/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

var _ = godotenv.Load()

var CmdThread = &base.Command{
var cmdThread = &base.Command{
Run: nil,
UsageLine: "slackdump tools thread [flags]",
Short: "thread utilities",
Expand All @@ -33,19 +33,19 @@ testing, i.e. deletion of the threads, or generation of large threads.
}

func init() {
CmdThread.Run = runThread
CmdThread.Flag.Usage = func() {
cmdThread.Run = runThread
cmdThread.Flag.Usage = func() {
fmt.Fprint(os.Stdout, "usage: slackdump diag thread [flags]\n\nFlags:\n")
CmdThread.Flag.PrintDefaults()
cmdThread.Flag.PrintDefaults()
}
}

var (
// TODO: test with client auth.
token = CmdThread.Flag.String("app-token", os.Getenv("APP_TOKEN"), "Slack application or bot token")
channel = CmdThread.Flag.String("channel", osenv.Value("CHANNEL", ""), "channel to operate on")
numThreadMsg = CmdThread.Flag.Int("num", 2, "number of messages to generate in the thread")
delThread = CmdThread.Flag.String("del", "", "`URL` of the thread to delete")
token = cmdThread.Flag.String("app-token", os.Getenv("APP_TOKEN"), "Slack application or bot token")
channel = cmdThread.Flag.String("channel", osenv.Value("CHANNEL", ""), "channel to operate on")
numThreadMsg = cmdThread.Flag.Int("num", 2, "number of messages to generate in the thread")
delThread = cmdThread.Flag.String("del", "", "`URL` of the thread to delete")
)

func runThread(ctx context.Context, cmd *base.Command, args []string) error {
Expand Down
22 changes: 11 additions & 11 deletions cmd/slackdump/internal/diag/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ Tools command contains different tools, running which may be requested if you op
PrintFlags: false,
RequireAuth: false,
Commands: []*base.Command{
CmdEdge,
CmdEncrypt,
CmdEzTest,
CmdInfo,
CmdObfuscate,
CmdRawOutput,
CmdUninstall,
CmdRecord,
cmdSearch,
CmdThread,
CmdWizDebug,
// cmdEdge,
dmdEncrypt,
dmdEzTest,
dmdInfo,
dmdObfuscate,
// cmdRawOutput,
cmdUninstall,
// cmdRecord,
// cmdSearch,
cmdThread,
// cmdWizDebug,
},
}
20 changes: 10 additions & 10 deletions cmd/slackdump/internal/diag/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/rusq/slackdump/v3/internal/cache"
)

var CmdUninstall = &base.Command{
var cmdUninstall = &base.Command{
UsageLine: "slackdump tools uninstall",
Short: "performs uninstallation of components",
RequireAuth: false,
Expand All @@ -29,7 +29,7 @@ var CmdUninstall = &base.Command{
}

func init() {
CmdUninstall.Wizard = wizUninstall
cmdUninstall.Wizard = wizUninstall
}

type uninstOptions struct {
Expand Down Expand Up @@ -77,13 +77,13 @@ func (o uninstOptions) String() string {
var uninstParams = uninstOptions{}

func init() {
CmdUninstall.Flag.BoolVar(&uninstParams.playwright, "legacy-browser", false, "alias for -playwright")
CmdUninstall.Flag.BoolVar(&uninstParams.playwright, "playwright", false, "remove playwright environment")
CmdUninstall.Flag.BoolVar(&uninstParams.rod, "browser", false, "remove rod browser")
CmdUninstall.Flag.BoolVar(&uninstParams.cache, "cache", false, "remove saved workspaces and user/channel cache")
CmdUninstall.Flag.BoolVar(&uninstParams.purge, "purge", false, "remove everything (same as -rod -playwright -cache)")
CmdUninstall.Flag.BoolVar(&uninstParams.dry, "dry", false, "dry run")
CmdUninstall.Flag.BoolVar(&uninstParams.noConfirm, "no-confirm", false, "no confirmation from the user")
cmdUninstall.Flag.BoolVar(&uninstParams.playwright, "legacy-browser", false, "alias for -playwright")
cmdUninstall.Flag.BoolVar(&uninstParams.playwright, "playwright", false, "remove playwright environment")
cmdUninstall.Flag.BoolVar(&uninstParams.rod, "browser", false, "remove rod browser")
cmdUninstall.Flag.BoolVar(&uninstParams.cache, "cache", false, "remove saved workspaces and user/channel cache")
cmdUninstall.Flag.BoolVar(&uninstParams.purge, "purge", false, "remove everything (same as -rod -playwright -cache)")
cmdUninstall.Flag.BoolVar(&uninstParams.dry, "dry", false, "dry run")
cmdUninstall.Flag.BoolVar(&uninstParams.noConfirm, "no-confirm", false, "no confirmation from the user")

}

Expand Down Expand Up @@ -201,7 +201,7 @@ func wizUninstall(ctx context.Context, cmd *base.Command, args []string) error {
Name: "Uninstall",
Title: "Uninstall Slackdump Components",
LocalConfig: uninstParams.configuration,
Cmd: CmdUninstall,
Cmd: cmdUninstall,
}
return w.Run(ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/slackdump/internal/diag/wizdebug.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/cfgui"
)

var CmdWizDebug = &base.Command{
var cmdWizDebug = &base.Command{
UsageLine: "slackdump tools wizdebug",
Short: "run the wizard debug command",
Run: runWizDebug,
Expand Down
18 changes: 18 additions & 0 deletions slackdump.1
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,24 @@ session by running
.Nm Cm help Ar login
.Be
.\"
.Sh TOOLS
The following tools are available:
.Bl -tag -width uninstall
.It Em encrypt
encrypt files for secure transmission, i.e. encrypting trace.out before
posting it in Github Issues.
.It Em eztest
test the EZ-LOGIN 3000 method.
.It Em info
show information about Slackdump environment
.It Em obfuscate
obfuscate the sensitive data in Slackdump archive. Works only on
archive file format.
.It Em uninstall
uninstall Slackdump components or purge it from the system.
.It Em thread
thread utility, used to create threads in the Slack workspace for tests.
.El
.Sh ENVIRONMENT
.Bl -tag -width SLACK_WORKSPACE
.It Ev BASE_LOC
Expand Down

0 comments on commit 293bb18

Please sign in to comment.