cmd

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "ptool",
	Short: "ptool is a command-line program which facilitates the use of private tracker sites and BitTorrent clients.",
	Long: `ptool is a command-line program which facilitates the use of private tracker sites and BitTorrent clients.
It's a free and open-source software released under the AGPL-3.0 license,
visit https://github.com/sagan/ptool for source codes and other infomation.`,

	SilenceErrors:      true,
	SilenceUsage:       true,
	DisableSuggestions: true,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		if config.InShell && config.Get().ShellMaxHistory > 0 {
			in := strings.Join(os.Args[1:], " ")
			ShellHistory.Write(in)
		}
	},
}

Root represents the base command when called without any subcommands

Functions

func AddEnumFlagP added in v0.1.6

func AddEnumFlagP(command *cobra.Command, value *string, name string, shorthand string, flag *EnumFlag)

func AddShellCompletion added in v0.1.6

func AddShellCompletion(name string, f func(document *prompt.Document) []prompt.Suggest)

cobra-prompt dynamic suggestions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func Exit added in v0.1.6

func Exit(code int)

clean all resources created during this session and exit

func ShellDynamicSuggestionsFunc added in v0.1.6

func ShellDynamicSuggestionsFunc(name string, document *prompt.Document) []prompt.Suggest

Types

type EnumFlag added in v0.1.6

type EnumFlag struct {
	DefaultOptionIndex int
	Description        string
	Options            [][2]string // array of [option, desc] pairs
}

an enum of string type

type EnumValue added in v0.1.6

type EnumValue struct {
	// contains filtered or unexported fields
}

func (*EnumValue) Set added in v0.1.6

func (ev *EnumValue) Set(value string) error

func (*EnumValue) String added in v0.1.6

func (ev *EnumValue) String() string

func (*EnumValue) Type added in v0.1.6

func (ev *EnumValue) Type() string

type ShellHistoryStruct added in v0.1.6

type ShellHistoryStruct struct {
	// contains filtered or unexported fields
}

direct construct, only filename field needed

var (
	ShellHistory *ShellHistoryStruct
)

func (*ShellHistoryStruct) Clear added in v0.1.6

func (sh *ShellHistoryStruct) Clear()

func (*ShellHistoryStruct) Load added in v0.1.6

func (sh *ShellHistoryStruct) Load() ([]string, error)

func (*ShellHistoryStruct) Truncate added in v0.1.6

func (sh *ShellHistoryStruct) Truncate(max int)

best effort

func (*ShellHistoryStruct) Write added in v0.1.6

func (sh *ShellHistoryStruct) Write(in string)

Jump to

Keyboard shortcuts

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