Skip to content

Commit

Permalink
Merge pull request #1899 from rsteube/cmd-remove-conditions
Browse files Browse the repository at this point in the history
carapace: remove conditions flag for now
  • Loading branch information
rsteube authored Oct 9, 2023
2 parents 7d94781 + b2a7a1f commit 6d1be99
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions cmd/carapace/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/rsteube/carapace-bin/cmd/carapace/cmd/completers"
"github.com/rsteube/carapace-bin/cmd/carapace/cmd/shim"
"github.com/rsteube/carapace-bin/pkg/actions"
"github.com/rsteube/carapace-bin/pkg/conditions"
spec "github.com/rsteube/carapace-spec"
"github.com/rsteube/carapace/pkg/ps"
"github.com/rsteube/carapace/pkg/style"
Expand Down Expand Up @@ -66,14 +65,6 @@ var rootCmd = &cobra.Command{
// since flag parsing is disabled do this manually
// TODO switch to cobra flag parsing with interspersed=false (redirect completion from completers/carapace_completer to here)
switch args[0] {
case "--conditions":
if len(args) > 1 {
//printCondition(args[1]) // TODO
} else {
fmt.Fprintln(cmd.OutOrStdout(), printConditions("yaml-short")) // TODO
}
case "--conditions=markdown":
fmt.Fprintln(cmd.OutOrStdout(), printConditions("markdown")) // TODO
case "--macros":
if len(args) > 1 {
printMacro(args[1])
Expand Down Expand Up @@ -312,30 +303,6 @@ func printCompletersJson() {
}
}

func printConditions(format string) string {
s := make([]string, 0)
switch format {
case "yaml-short":
// TODO marshal ordered using yaml
for name, macro := range conditions.MacroMap {
s = append(s, fmt.Sprintf("%v: %#v", name, macro.Description))
}

case "markdown":
sortedNames := make([]string, 0)
for name := range conditions.MacroMap {
sortedNames = append(sortedNames, name)
}
sort.Strings(sortedNames)

s = append(s, "# Conditions", "")
for _, name := range sortedNames {
s = append(s, fmt.Sprintf("- [%v](https://pkg.go.dev/github.com/rsteube/carapace-bin/pkg/conditions#Condition%v) %v", name, name, conditions.MacroMap[name].Description))
}
}
return strings.Join(s, "\n")
}

func printMacros() {
maxlen := 0
names := make([]string, 0)
Expand Down

0 comments on commit 6d1be99

Please sign in to comment.