summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/cobra/cobra.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cobra/cobra.go')
-rw-r--r--vendor/github.com/spf13/cobra/cobra.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/vendor/github.com/spf13/cobra/cobra.go b/vendor/github.com/spf13/cobra/cobra.go
index d6cbfd7198..fe44bc8a07 100644
--- a/vendor/github.com/spf13/cobra/cobra.go
+++ b/vendor/github.com/spf13/cobra/cobra.go
@@ -1,9 +1,10 @@
-// Copyright © 2013 Steve Francia <spf@spf13.com>.
+// Copyright 2013-2022 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
+//
+// 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,
@@ -39,15 +40,25 @@ var templateFuncs = template.FuncMap{
}
var initializers []func()
+var finalizers []func()
+
+const (
+ defaultPrefixMatching = false
+ defaultCommandSorting = true
+ defaultCaseInsensitive = false
+)
// EnablePrefixMatching allows to set automatic prefix matching. Automatic prefix matching can be a dangerous thing
// to automatically enable in CLI tools.
// Set this to true to enable it.
-var EnablePrefixMatching = false
+var EnablePrefixMatching = defaultPrefixMatching
// EnableCommandSorting controls sorting of the slice of commands, which is turned on by default.
// To disable sorting, set it to false.
-var EnableCommandSorting = true
+var EnableCommandSorting = defaultCommandSorting
+
+// EnableCaseInsensitive allows case-insensitive commands names. (case sensitive by default)
+var EnableCaseInsensitive = defaultCaseInsensitive
// MousetrapHelpText enables an information splash screen on Windows
// if the CLI is started from explorer.exe.
@@ -84,6 +95,12 @@ func OnInitialize(y ...func()) {
initializers = append(initializers, y...)
}
+// OnFinalize sets the passed functions to be run when each command's
+// Execute method is terminated.
+func OnFinalize(y ...func()) {
+ finalizers = append(finalizers, y...)
+}
+
// FIXME Gt is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra.
// Gt takes two types and checks whether the first type is greater than the second. In case of types Arrays, Chans,