Skip to content

Commit ebac793

Browse files
committed
tf show command without arguments or with plan works as original
1 parent 4aca9a2 commit ebac793

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

run/list.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ func List(args []string) error {
1717
}
1818
}
1919

20-
patternIgnoreFooter := ""
21-
return terraformWithoutColors("state", newArgs, patternIgnoreFooter)
20+
return terraformWithoutColors("state", newArgs)
2221
}

run/show.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,28 @@ func Show(args []string) error {
1212
resources := []string{}
1313
newArgs := []string{}
1414

15-
noOutputs := true
16-
1715
for _, arg := range args {
18-
if arg == "-no-output" || arg == "-no-outputs" {
19-
noOutputs = true
20-
} else if arg == "-no-output=false" || arg == "-no-outputs=false" {
21-
noOutputs = false
22-
} else if strings.HasPrefix(arg, "-") {
16+
if strings.HasPrefix(arg, "-") {
2317
newArgs = append(newArgs, arg)
2418
} else if _, err := os.Stat(arg); err == nil {
2519
newArgs = append(newArgs, arg)
2620
} else {
2721
resources = append(resources, util.AddQuotes(arg))
2822
}
29-
3023
}
3124

32-
patternIgnoreFooter := ""
33-
3425
if len(resources) > 0 {
3526
newArgs = append([]string{"show"}, newArgs...)
3627
for i, r := range resources {
3728
if i > 0 {
3829
fmt.Println()
3930
}
40-
if err := terraformWithoutColors("state", append(newArgs, r), patternIgnoreFooter); err != nil {
31+
if err := terraformWithoutColors("state", append(newArgs, r)); err != nil {
4132
return err
4233
}
4334
}
4435
return nil
4536
}
4637

47-
if noOutputs {
48-
patternIgnoreFooter = `^Outputs:$`
49-
}
50-
return terraformWithoutColors("show", newArgs, patternIgnoreFooter)
38+
return Terraform("show", newArgs)
5139
}

run/terraform_without_colors.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ import (
55
"fmt"
66
"os"
77
"os/signal"
8-
"regexp"
98
"syscall"
109

1110
"github.com/dex4er/tf/util"
1211
)
1312

14-
func terraformWithoutColors(command string, args []string, patternIgnoreFooter string) error {
15-
reIgnoreFooter := regexp.MustCompile(patternIgnoreFooter)
16-
13+
func terraformWithoutColors(command string, args []string) error {
1714
signal.Ignore(syscall.SIGINT)
1815

1916
cmd := execTerraformCommand(append([]string{command}, args...)...)
@@ -42,12 +39,6 @@ func terraformWithoutColors(command string, args []string, patternIgnoreFooter s
4239
line := scanner.Text()
4340
line = util.RemoveColors(line)
4441

45-
// ignore from this line to the end
46-
if patternIgnoreFooter != "" && reIgnoreFooter.MatchString(line) {
47-
ignoreFooter = true
48-
continue
49-
}
50-
5142
fmt.Println(line)
5243
}
5344

0 commit comments

Comments
 (0)