Fix redefined RE init flags by feluelle · Pull Request #1953 · astronomer/astro-cli

Under certain circumstances such as when the context cannot be retrieved and the platform hasn't been selected, we would define the new remote-execution-enabled flag twice. This change ensures that we only define it once.

FAILED dev_test.py::test_dev_init - AssertionError: assert 2 == 0
 +  where 2 = CompletedProcess(args=['/home/circleci/project/astro', 'dev', 'init'], returncode=2, stdout='', stderr='panic: init flag redefined: remote-execution-enabled\n\ngoroutine 1 [running]:\ngithub.com/spf13/pflag.(*FlagSet).AddFlag(0xc0003f6b00, 0xc0004c6e60)\n\t/home/circleci/.go_workspace/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:848 +0x5fc\ngithub.com/spf13/pflag.(*FlagSet).VarPF(0xc0003f6b00, {0x301ddb0, 0x477b8ab}, {0x2be943b, 0x18}, {0x0, 0x0}, {0x2c9ca39, 0x9f})\n\t/home/circleci/.go_workspace/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:831 +0x105\ngithub.com/spf13/pflag.(*FlagSet).BoolVarP(0xc0003f6b00?, 0x2be9453?, {0x2be943b?, 0x0?}, {0x0?, 0x0?}, 0x0?, {0x2c9ca39?, 0x0?})\n\t/home/circleci/.go_workspace/pkg/mod/github.com/spf13/pflag@v1.0.5/bool.go:55 +0x3e\ngithub.com/astronomer/astro-cli/cmd.newAirflowInitCmd()\n\t/home/circleci/project/cmd/airflow.go:206 +0x5c5\ngithub.com/astronomer/astro-cli/cmd.newDevRootCmd({0x305ffd0, 0xc0002fc9c0}, {0x306ee18, 0xc0002fc9a0})\n\t/home/circleci/project/cmd/airflow.go:152 +0x192\ngithub.com/astronomer/astro-cli/cmd.NewRootCmd()\n\t/home/circleci/project/cmd/root.go:78 +0x636\nmain.main()\n\t/home/circleci/project/main.go:21 +0x2a\n').returncode