Documentation ¶
Index ¶
- Variables
- func AddEnumFlagP(command *cobra.Command, value *string, name string, shorthand string, ...)
- func AddShellCompletion(name string, f func(document *prompt.Document) []prompt.Suggest)
- func Execute()
- func Exit(code int)
- func ShellDynamicSuggestionsFunc(name string, document *prompt.Document) []prompt.Suggest
- type EnumFlag
- type EnumValue
- type ShellHistoryStruct
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 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
}
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)
Click to show internal directories.
Click to hide internal directories.