Work around a few global flag collisions for ssh command

* `vagrant ssh` has a --no-tty flag colliding with the one defined in
   `bin/vagrant` - in fact none of the flags in `bin/vagrant` are
   processed in `serve` mode, so remove the code that captures them from
   the CommandInfo OptionParser dance
 * `vagrant ssh` has a `--plain` flag colliding with the one defined in
   `internal/cli/base.go` - this flag was inherited from Waypoint, so we
   can just rename it to line up with the (inversely defined) `--color`
   flag used in legacy vagrant
This commit is contained in:
Paul Hinze 2022-03-16 16:34:29 -05:00
parent 57babc2f79
commit 7f56168959
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 7 additions and 7 deletions

View File

@ -72,8 +72,8 @@ type baseCommand struct {
//--------------------------------------------------------------- //---------------------------------------------------------------
// Internal fields that should not be accessed directly // Internal fields that should not be accessed directly
// flagPlain is whether the output should be in plain mode. // flagColor is whether the output should use colors.
flagPlain bool flagColor bool
// flagRemote is whether to execute using a remote runner or use // flagRemote is whether to execute using a remote runner or use
// a local runner. // a local runner.
@ -295,7 +295,7 @@ func (c *baseCommand) Init(opts ...Option) (err error) {
} }
// Reset the UI to plain if that was set // Reset the UI to plain if that was set
if c.flagPlain { if !c.flagColor {
c.ui = terminal.NonInteractiveUI(c.Ctx) c.ui = terminal.NonInteractiveUI(c.Ctx)
} }
@ -378,9 +378,9 @@ func (c *baseCommand) logError(log hclog.Logger, prefix string, err error) {
func (c *baseCommand) flagSet(bit flagSetBit, f func([]*component.CommandFlag) []*component.CommandFlag) component.CommandFlags { func (c *baseCommand) flagSet(bit flagSetBit, f func([]*component.CommandFlag) []*component.CommandFlag) component.CommandFlags {
set := []*component.CommandFlag{ set := []*component.CommandFlag{
{ {
LongName: "plain", LongName: "color",
Description: "Plain output: no colors, no animation", Description: "Can be used to disable colored output",
DefaultValue: "false", DefaultValue: "true",
Type: component.FlagBool, Type: component.FlagBool,
}, },
{ {

View File

@ -216,7 +216,7 @@ module VagrantPlugins
# Now we need a customized class to get the new behavior # Now we need a customized class to get the new behavior
# that we want # that we want
optparse_klass = Class.new(VagrantPlugins.const_get(:VagrantOriginalOptionParser)) do optparse_klass = Class.new(::OptionParser) do
def initialize(*args, &block) def initialize(*args, &block)
super(*args, &block) super(*args, &block)
Thread.current.thread_variable_set(:command_options, self) Thread.current.thread_variable_set(:command_options, self)