Skip to content

Commit

Permalink
Drop VSCode-specific flag.
Browse files Browse the repository at this point in the history
It's no longer needed.
  • Loading branch information
mitchell-as committed Oct 30, 2023
1 parent 4dcb93d commit 1c1269c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 38 deletions.
8 changes: 0 additions & 8 deletions cmd/state/internal/cmdtree/cmdtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,6 @@ func newStateCommand(globals *globalOptions, prime *primer.Values) *captain.Comm
Persist: true,
Value: &globals.Output,
},
{
/* This option is only used for the vscode extension: It prevents the integrated terminal to close immediately after an error occurs, such that the user can read the message */
Name: "confirm-exit-on-error", // Name and Shorthand should be kept in sync with cmd/state/output.go
Description: "prompts the user to press enter before exiting, when an error occurs",
Persist: true,
Hidden: true, // No need to add this to help messages
Value: &opts.ConfirmExit,
},
{
Name: "non-interactive", // Name and Shorthand should be kept in sync with cmd/state/output.go
Description: locale.T("flag_state_non_interactive_description"),
Expand Down
14 changes: 0 additions & 14 deletions cmd/state/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package main

import (
"bufio"
"context"
"errors"
"fmt"
"os"
"os/exec"
"runtime/debug"
"strings"
"time"
Expand Down Expand Up @@ -108,17 +105,6 @@ func main() {
if err != nil {
out.Error(err)
}

// If a state tool error occurs in a VSCode integrated terminal, we want
// to pause and give time to the user to read the error message.
// But not, if we exit, because the last command in the activated sub-shell failed.
var eerr *exec.ExitError
isExitError := errors.As(err, &eerr)
if !isExitError && outFlags.ConfirmExit {
out.Print(locale.T("confirm_exit_on_error_prompt"))
br := bufio.NewReader(os.Stdin)
br.ReadLine()
}
}
}

Expand Down
25 changes: 12 additions & 13 deletions cmd/state/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,44 @@ type MainTestSuite struct {

func (suite *MainTestSuite) TestOutputer() {
{
outputer, err := initOutput(outputFlags{"", false, false, false}, "", "")
outputer, err := initOutput(outputFlags{"", false, false}, "", "")
suite.Require().NoError(err, errs.JoinMessage(err))
suite.Equal(output.PlainFormatName, outputer.Type(), "Returns Plain outputer")
}

{
outputer, err := initOutput(outputFlags{string(output.PlainFormatName), false, false, false}, "", "")
outputer, err := initOutput(outputFlags{string(output.PlainFormatName), false, false}, "", "")
suite.Require().NoError(err)
suite.Equal(output.PlainFormatName, outputer.Type(), "Returns Plain outputer")
}

{
outputer, err := initOutput(outputFlags{string(output.JSONFormatName), false, false, false}, "", "")
outputer, err := initOutput(outputFlags{string(output.JSONFormatName), false, false}, "", "")
suite.Require().NoError(err)
suite.Equal(output.JSONFormatName, outputer.Type(), "Returns JSON outputer")
}

{
outputer, err := initOutput(outputFlags{"", false, false, false}, string(output.JSONFormatName), "")
outputer, err := initOutput(outputFlags{"", false, false}, string(output.JSONFormatName), "")
suite.Require().NoError(err)
suite.Equal(output.JSONFormatName, outputer.Type(), "Returns JSON outputer")
}

{
outputer, err := initOutput(outputFlags{"", false, false, false}, string(output.EditorFormatName), "")
outputer, err := initOutput(outputFlags{"", false, false}, string(output.EditorFormatName), "")
suite.Require().NoError(err)
suite.Equal(output.EditorFormatName, outputer.Type(), "Returns JSON outputer")
}
}

func (suite *MainTestSuite) TestParseOutputFlags() {
suite.Equal(outputFlags{"plain", false, false, false}, parseOutputFlags([]string{"state", "foo", "-o", "plain"}))
suite.Equal(outputFlags{"json", false, false, false}, parseOutputFlags([]string{"state", "foo", "--output", "json"}))
suite.Equal(outputFlags{"json", false, false, false}, parseOutputFlags([]string{"state", "foo", "-o", "json"}))
suite.Equal(outputFlags{"editor", false, false, false}, parseOutputFlags([]string{"state", "foo", "--output", "editor"}))
suite.Equal(outputFlags{"", true, false, false}, parseOutputFlags([]string{"state", "foo", "--mono"}))
suite.Equal(outputFlags{"", false, true, false}, parseOutputFlags([]string{"state", "foo", "--confirm-exit-on-error"}))
suite.Equal(outputFlags{"", false, false, true}, parseOutputFlags([]string{"state", "foo", "--non-interactive"}))
suite.Equal(outputFlags{"", false, false, true}, parseOutputFlags([]string{"state", "foo", "-n"}))
suite.Equal(outputFlags{"plain", false, false}, parseOutputFlags([]string{"state", "foo", "-o", "plain"}))
suite.Equal(outputFlags{"json", false, false}, parseOutputFlags([]string{"state", "foo", "--output", "json"}))
suite.Equal(outputFlags{"json", false, false}, parseOutputFlags([]string{"state", "foo", "-o", "json"}))
suite.Equal(outputFlags{"editor", false, false}, parseOutputFlags([]string{"state", "foo", "--output", "editor"}))
suite.Equal(outputFlags{"", true, false}, parseOutputFlags([]string{"state", "foo", "--mono"}))
suite.Equal(outputFlags{"", false, true}, parseOutputFlags([]string{"state", "foo", "--non-interactive"}))
suite.Equal(outputFlags{"", false, true}, parseOutputFlags([]string{"state", "foo", "-n"}))
}

func (suite *MainTestSuite) TestDisableColors() {
Expand Down
1 change: 0 additions & 1 deletion cmd/state/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type outputFlags struct {
// These should be kept in sync with cmd/state/internal/cmdtree (output flag)
Output string `short:"o" long:"output"`
Mono bool `long:"mono"`
ConfirmExit bool `long:"confirm-exit-on-error"`
NonInteractive bool `short:"n" long:"non-interactive"`
}

Expand Down
2 changes: 0 additions & 2 deletions internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,6 @@ deploy_usable_path:
Please ensure '[NOTICE]{{.V0}}[/RESET]' exists and is on your PATH.
script_watcher_watch_file:
other: "Watching file changes at: [NOTICE]{{.V0}}[/RESET]"
confirm_exit_on_error_prompt:
other: Press enter to continue...
tutorial_newproject_intro:
other: |
The State Tool lets you create and maintain a set of virtual environments (eg., one per project), allowing you to
Expand Down

0 comments on commit 1c1269c

Please sign in to comment.