• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb / mongodb-atlas-cli / 26228926989

21 May 2026 01:27PM UTC coverage: 22.63% (-41.6%) from 64.198%
26228926989

push

github

apix-bot[bot]
Update compliance report for v1.55.0

8987 of 39713 relevant lines covered (22.63%)

0.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.58
/internal/cli/cli.go
1
// Copyright 2024 MongoDB Inc
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
package cli
16

17
import (
18
        "strings"
19

20
        "github.com/spf13/cobra"
21
        "github.com/tangzero/inflector"
22
)
23

24
type AutoFunc func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
25

26
// GenerateAliases return aliases for use such that they are:
27
// a version all lower case, a version with dashes, a singular versions with the same rules.
28
func GenerateAliases(use string, extra ...string) []string {
1✔
29
        aliases := make([]string, 0)
1✔
30

1✔
31
        if lower := strings.ToLower(use); lower != use {
2✔
32
                aliases = append(aliases, lower)
1✔
33
        }
1✔
34
        if dash := inflector.Dasherize(use); dash != use {
2✔
35
                aliases = append(aliases, dash)
1✔
36
        }
1✔
37
        if singular := inflector.Singularize(use); singular != use {
2✔
38
                aliases = append(aliases, singular)
1✔
39
                if lower := strings.ToLower(singular); lower != singular {
2✔
40
                        aliases = append(aliases, lower)
1✔
41
                }
1✔
42
                if dash := inflector.Dasherize(singular); dash != singular {
2✔
43
                        aliases = append(aliases, dash)
1✔
44
                }
1✔
45
        }
46
        aliases = append(aliases, extra...)
1✔
47
        return aliases
1✔
48
}
49

50
// ReturnValueForSetting returns a boolean value that is useful when working with boolean flags to inform
51
// whether the given option should be active or inactive.
52
func ReturnValueForSetting(enableFlag, disableFlag bool) *bool {
×
53
        var valueToSet bool
×
54
        if enableFlag && disableFlag {
×
55
                return nil
×
56
        }
×
57
        if enableFlag {
×
58
                valueToSet = true
×
59
                return &valueToSet
×
60
        }
×
61
        if disableFlag {
×
62
                valueToSet = false
×
63
                return &valueToSet
×
64
        }
×
65
        return nil
×
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc