base

package
v3.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2025 License: GPL-3.0, BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package base defines shared basic pieces of the slackdump command.

Index

Constants

This section is empty.

Variables

View Source
var CmdName string
View Source
var Slackdump = &Command{
	UsageLine: "slackdump",
	Long: `
Slackdump is a tool for exporting Slack conversations, emojis, users, etc.

This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions.  Read LICENSE for more information.
`,
}
View Source
var Usage func()

Usage is the usage-reporting function, filled in by package main but here for reference by other packages.

Functions

func AtExit

func AtExit(f func())

func Executable

func Executable() string

Executable returns the name of the executable for the current OS.

func Exit

func Exit()

func Render

func Render(s string) string

Render renders the string formatted as markdown into a string with escape sequences for the terminal output. The width of output is calculated based on the terminal width.

func SetExitStatus

func SetExitStatus(n StatusCode)

func YesNo

func YesNo(message string) bool

func YesNoWR

func YesNoWR(w io.Writer, r io.Reader, message string) bool

Types

type Command

type Command struct {
	// Run runs the command.
	// The args are the arguments after the command name.
	Run func(ctx context.Context, cmd *Command, args []string) error

	Wizard func(ctx context.Context, cmd *Command, args []string) error

	// UsageLine is the one-line usage message.
	UsageLine string

	// Short is the short description shown in the 'slackdump help' output.
	Short string

	// Long is the long message shown in the 'slackdump help <this-command>' output.
	Long string

	// Flag is a set of flags specific to this command.
	Flag flag.FlagSet

	// CustomFlags indicates that the command will do its own
	// flag parsing.
	CustomFlags bool

	// FlagMask specifies the flags to be used with the command.
	FlagMask cfg.FlagMask

	// PrintFlags indicates that generic help handler should print the
	// flags in the flagset.  Set it to false, if a Long lists all the flags.
	// It only matters for the commands that have no subcommands.
	PrintFlags bool

	// RequireAuth is a flag that indicates that the command requires
	// authentication.
	RequireAuth bool

	// Commands lists the available commands and help topics.
	// The order here is the order in which they are printed by 'slackdump help'.
	// Note that subcommands are in general best avoided.
	Commands []*Command

	//HideWizard if set to true disables the display in wizard.
	HideWizard bool
}

A Command is an implementation of a slackdump command.

func (*Command) LongName

func (c *Command) LongName() string

LongName returns the command's long name: all the words in the usage line between "go" and a flag or argument,

func (*Command) Markdown

func (c *Command) Markdown() string

func (*Command) Name

func (c *Command) Name() string

Name returns the command's short name: the last word in the usage line before a flag or argument.

func (*Command) Runnable

func (c *Command) Runnable() bool

Runnable reports whether the command can be run; otherwise it is a documentation pseudo-command such as importpath.

func (*Command) Usage

func (c *Command) Usage()

type StatusCode

type StatusCode uint8

StatusCode is the code returned to the OS.

const (
	SNoError             StatusCode = iota // No Error
	SGenericError                          // Generic Error
	SHelpRequested                         // Help Requested
	SInvalidParameters                     // Invalid Parameters
	SAuthError                             // Authentication Error
	SInitializationError                   // Initialization Error
	SApplicationError                      // Application Error
	SWorkspaceError                        // Workspace Error
	SCacheError                            // Cache Error
	SUserError                             // User Error
	SCancelled                             // Cancelled
)

Status codes returned by the main executable.

func ExitStatus

func ExitStatus() (sc StatusCode)

func (StatusCode) String

func (i StatusCode) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL