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

nats-io / nsc / 14765656943

30 Apr 2025 10:34PM UTC coverage: 69.949% (-4.2%) from 74.148%
14765656943

Pull #691

github

web-flow
Merge b4ee16f94 into a9c0df586
Pull Request #691: Generate docs

1 of 1 new or added line in 1 file covered. (100.0%)

3680 existing lines in 93 files now uncovered.

12325 of 17620 relevant lines covered (69.95%)

1.66 hits per line

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

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

14
package cmd
15

16
import (
17
        "github.com/spf13/cobra"
18
)
19

20
func init() {
21
        GetRootCmd().AddCommand(createSelecteCmd())
22
}
2✔
23

2✔
24
func createSelecteCmd() *cobra.Command {
2✔
25
        cmd := &cobra.Command{
26
                Use:   "select",
2✔
27
                Short: "Set the current operator or account",
2✔
28
        }
2✔
29
        cmd.AddCommand(selectOperatorCmd())
2✔
30
        cmd.AddCommand(selectAccountCmd())
2✔
31
        return cmd
2✔
32
}
2✔
33

2✔
34
func selectOperatorCmd() *cobra.Command {
2✔
35
        return &cobra.Command{
36
                Use:   "operator",
2✔
37
                Short: "set the operator",
2✔
38
                Args: func(cmd *cobra.Command, args []string) error {
2✔
39
                        if err := cobra.ExactArgs(1)(cmd, args); err != nil {
2✔
40
                                return err
4✔
41
                        }
2✔
UNCOV
42

×
UNCOV
43
                        return nil
×
44
                },
45
                RunE: func(cmd *cobra.Command, args []string) error {
2✔
46
                        current := GetConfig()
47
                        if err := current.ContextConfig.Update("", args[0], ""); err != nil {
2✔
48
                                return err
2✔
49
                        }
4✔
50

2✔
51
                        return current.Save()
2✔
52
                },
53
        }
2✔
54
}
55

56
func selectAccountCmd() *cobra.Command {
57
        return &cobra.Command{
58
                Use:   "account",
2✔
59
                Short: "set the account",
2✔
60
                Args: func(cmd *cobra.Command, args []string) error {
2✔
61
                        if err := cobra.ExactArgs(1)(cmd, args); err != nil {
2✔
62
                                return err
4✔
63
                        }
2✔
UNCOV
64

×
UNCOV
65
                        return nil
×
66
                },
67
                RunE: func(cmd *cobra.Command, args []string) error {
2✔
68
                        current := GetConfig()
69
                        if err := current.ContextConfig.Update("", "", args[0]); err != nil {
2✔
70
                                return err
2✔
71
                        }
4✔
72

2✔
73
                        return current.Save()
2✔
74
                },
75
        }
2✔
76
}
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

© 2025 Coveralls, Inc