Skip to content

Commit 1da1001

Browse files
authored
Merge pull request #69 from reeflective/dev
dev
2 parents c24827d + e07b7e0 commit 1da1001

File tree

15 files changed

+661
-574
lines changed

15 files changed

+661
-574
lines changed

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,3 @@ The library is in a pre-release candidate status:
9999

100100
Please open a PR or an issue if you wish to bring enhancements to it.
101101
Other contributions, as well as bug fixes and reviews are also welcome.
102-
103-
104-
## Possible Improvements
105-
106-
The following is a currently moving list of possible enhancements to be made in order to reach `v1.0`:
107-
- [ ] Ensure to the best extent possible a thread-safe access to the command API.
108-
- [ ] Clearer integration/alignment of the various I/O references between raw readline and commands.
109-
- [ ] Clearer and sane model for asynchronous control/cancel of commands (with OnKillRun in cobra)
110-
- [ ] Test suite for most important or risky code paths.

command.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package console
22

33
import (
44
"github.com/spf13/cobra"
5-
"github.com/spf13/pflag"
65
)
76

87
const (
@@ -74,39 +73,3 @@ next:
7473

7574
c.filters = updated
7675
}
77-
78-
// resetFlagsDefaults resets all flags to their default values.
79-
//
80-
// Slice flags accumulate per execution (and do not reset),
81-
//
82-
// so we must reset them manually.
83-
//
84-
// Example:
85-
//
86-
// Given cmd.Flags().StringSlice("comment", nil, "")
87-
// If you run a command with --comment "a" --comment "b" you will get
88-
// the expected [a, b] slice.
89-
//
90-
// If you run a command again with no --comment flags, you will get
91-
// [a, b] again instead of an empty slice.
92-
//
93-
// If you run the command again with --comment "c" --comment "d" flags,
94-
// you will get [a, b, c, d] instead of just [c, d].
95-
func resetFlagsDefaults(target *cobra.Command) {
96-
target.Flags().VisitAll(func(flag *pflag.Flag) {
97-
flag.Changed = false
98-
switch value := flag.Value.(type) {
99-
case pflag.SliceValue:
100-
var res []string
101-
102-
if len(flag.DefValue) > 0 && flag.DefValue != "[]" {
103-
res = append(res, flag.DefValue)
104-
}
105-
106-
value.Replace(res)
107-
108-
default:
109-
flag.Value.Set(flag.DefValue)
110-
}
111-
})
112-
}

0 commit comments

Comments
 (0)