From 293bb1869d3b1fe0cee321724707cfb941d3999e Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Fri, 22 Nov 2024 21:29:46 +1000 Subject: [PATCH] disable useless tools --- cmd/slackdump/internal/diag/edge.go | 4 ++-- cmd/slackdump/internal/diag/encrypt.go | 6 +++--- cmd/slackdump/internal/diag/eztest.go | 12 ++++++------ cmd/slackdump/internal/diag/info.go | 6 +++--- cmd/slackdump/internal/diag/obfuscate.go | 22 +++++++++++----------- cmd/slackdump/internal/diag/rawoutput.go | 6 +++--- cmd/slackdump/internal/diag/record.go | 2 +- cmd/slackdump/internal/diag/thread.go | 16 ++++++++-------- cmd/slackdump/internal/diag/tools.go | 22 +++++++++++----------- cmd/slackdump/internal/diag/uninstall.go | 20 ++++++++++---------- cmd/slackdump/internal/diag/wizdebug.go | 2 +- slackdump.1 | 18 ++++++++++++++++++ 12 files changed, 77 insertions(+), 59 deletions(-) diff --git a/cmd/slackdump/internal/diag/edge.go b/cmd/slackdump/internal/diag/edge.go index 3c4c13bd..6bef250c 100644 --- a/cmd/slackdump/internal/diag/edge.go +++ b/cmd/slackdump/internal/diag/edge.go @@ -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", @@ -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 { diff --git a/cmd/slackdump/internal/diag/encrypt.go b/cmd/slackdump/internal/diag/encrypt.go index 7767de90..5d18ee03 100644 --- a/cmd/slackdump/internal/diag/encrypt.go +++ b/cmd/slackdump/internal/diag/encrypt.go @@ -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", @@ -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 { diff --git a/cmd/slackdump/internal/diag/eztest.go b/cmd/slackdump/internal/diag/eztest.go index 4b09e7a7..ee6f9aaf 100644 --- a/cmd/slackdump/internal/diag/eztest.go +++ b/cmd/slackdump/internal/diag/eztest.go @@ -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", @@ -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 { diff --git a/cmd/slackdump/internal/diag/info.go b/cmd/slackdump/internal/diag/info.go index 0bd5bd70..4f7e1d0c 100644 --- a/cmd/slackdump/internal/diag/info.go +++ b/cmd/slackdump/internal/diag/info.go @@ -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, @@ -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 { diff --git a/cmd/slackdump/internal/diag/obfuscate.go b/cmd/slackdump/internal/diag/obfuscate.go index 6c815fb7..45b1f8a5 100644 --- a/cmd/slackdump/internal/diag/obfuscate.go +++ b/cmd/slackdump/internal/diag/obfuscate.go @@ -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: ` @@ -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 ( @@ -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 = "-" diff --git a/cmd/slackdump/internal/diag/rawoutput.go b/cmd/slackdump/internal/diag/rawoutput.go index c166feda..a71d96a8 100644 --- a/cmd/slackdump/internal/diag/rawoutput.go +++ b/cmd/slackdump/internal/diag/rawoutput.go @@ -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] ", Short: "record raw API output", @@ -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 { diff --git a/cmd/slackdump/internal/diag/record.go b/cmd/slackdump/internal/diag/record.go index af5d05d1..f7d637b3 100644 --- a/cmd/slackdump/internal/diag/record.go +++ b/cmd/slackdump/internal/diag/record.go @@ -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}, diff --git a/cmd/slackdump/internal/diag/thread.go b/cmd/slackdump/internal/diag/thread.go index 0f2f25aa..2799eef5 100644 --- a/cmd/slackdump/internal/diag/thread.go +++ b/cmd/slackdump/internal/diag/thread.go @@ -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", @@ -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 { diff --git a/cmd/slackdump/internal/diag/tools.go b/cmd/slackdump/internal/diag/tools.go index 126f50dd..98e49e42 100644 --- a/cmd/slackdump/internal/diag/tools.go +++ b/cmd/slackdump/internal/diag/tools.go @@ -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, }, } diff --git a/cmd/slackdump/internal/diag/uninstall.go b/cmd/slackdump/internal/diag/uninstall.go index d99c5484..6df4f90e 100644 --- a/cmd/slackdump/internal/diag/uninstall.go +++ b/cmd/slackdump/internal/diag/uninstall.go @@ -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, @@ -29,7 +29,7 @@ var CmdUninstall = &base.Command{ } func init() { - CmdUninstall.Wizard = wizUninstall + cmdUninstall.Wizard = wizUninstall } type uninstOptions struct { @@ -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") } @@ -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) } diff --git a/cmd/slackdump/internal/diag/wizdebug.go b/cmd/slackdump/internal/diag/wizdebug.go index 097fe76e..4e2facf2 100644 --- a/cmd/slackdump/internal/diag/wizdebug.go +++ b/cmd/slackdump/internal/diag/wizdebug.go @@ -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, diff --git a/slackdump.1 b/slackdump.1 index 3da9634e..f5e36e58 100644 --- a/slackdump.1 +++ b/slackdump.1 @@ -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