Source File
shell_completions.go
Belonging Package
github.com/spf13/cobra
// Copyright 2013-2023 The Cobra Authors//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.package cobraimport ()// MarkFlagRequired instructs the various shell completion implementations to// prioritize the named flag when performing completion,// and causes your command to report an error if invoked without the flag.func ( *Command) ( string) error {return MarkFlagRequired(.Flags(), )}// MarkPersistentFlagRequired instructs the various shell completion implementations to// prioritize the named persistent flag when performing completion,// and causes your command to report an error if invoked without the flag.func ( *Command) ( string) error {return MarkFlagRequired(.PersistentFlags(), )}// MarkFlagRequired instructs the various shell completion implementations to// prioritize the named flag when performing completion,// and causes your command to report an error if invoked without the flag.func ( *pflag.FlagSet, string) error {return .SetAnnotation(, BashCompOneRequiredFlag, []string{"true"})}// MarkFlagFilename instructs the various shell completion implementations to// limit completions for the named flag to the specified file extensions.func ( *Command) ( string, ...string) error {return MarkFlagFilename(.Flags(), , ...)}// MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists.// The bash completion script will call the bash function f for the flag.//// This will only work for bash completion.// It is recommended to instead use c.RegisterFlagCompletionFunc(...) which allows// to register a Go function which will work across all shells.func ( *Command) ( string, string) error {return MarkFlagCustom(.Flags(), , )}// MarkPersistentFlagFilename instructs the various shell completion// implementations to limit completions for the named persistent flag to the// specified file extensions.func ( *Command) ( string, ...string) error {return MarkFlagFilename(.PersistentFlags(), , ...)}// MarkFlagFilename instructs the various shell completion implementations to// limit completions for the named flag to the specified file extensions.func ( *pflag.FlagSet, string, ...string) error {return .SetAnnotation(, BashCompFilenameExt, )}// MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists.// The bash completion script will call the bash function f for the flag.//// This will only work for bash completion.// It is recommended to instead use c.RegisterFlagCompletionFunc(...) which allows// to register a Go function which will work across all shells.func ( *pflag.FlagSet, string, string) error {return .SetAnnotation(, BashCompCustom, []string{})}// MarkFlagDirname instructs the various shell completion implementations to// limit completions for the named flag to directory names.func ( *Command) ( string) error {return MarkFlagDirname(.Flags(), )}// MarkPersistentFlagDirname instructs the various shell completion// implementations to limit completions for the named persistent flag to// directory names.func ( *Command) ( string) error {return MarkFlagDirname(.PersistentFlags(), )}// MarkFlagDirname instructs the various shell completion implementations to// limit completions for the named flag to directory names.func ( *pflag.FlagSet, string) error {return .SetAnnotation(, BashCompSubdirsInDir, []string{})}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |