Repository: quarkusio/quarkus
Issue: CLI cannot remove registry from the list

### Describe the bug

Registries added to cli cannot be removed

### Expected behavior

Attempts to remove registries from config should be successfull

### Actual behavior

Attempt to remove a registry from the list leads to error `Can only remove registries from an existing configuration. The specified config file does not exist: null`

### How to Reproduce?

1.  `quarkus registry add quarkus.example.com`
2. Check the list:
``` 
$ quarkus registry
Configured Quarkus extension registries:
registry.quarkus.io
quarkus.example.com
(Config source: file: ~/.quarkus/config.yaml)
```
2. `$ quarkus registry remove quarkus.example.com`

### Output of `uname -a` or `ver`

OS name: "linux", version: "5.15.6-100.fc34.x86_64"

### Output of `java -version`

11.0.13, vendor: Eclipse Adoptium

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.6.2.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java, devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java, devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java

diff --git a/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java b/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java
index 7ce770d8546..284b57a0c63 100644
--- a/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java
+++ b/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java
@@ -7,6 +7,7 @@
 
 import io.quarkus.cli.registry.BaseRegistryCommand;
 import io.quarkus.registry.config.RegistriesConfig;
+import io.quarkus.registry.config.RegistryConfig;
 import picocli.CommandLine;
 
 @CommandLine.Command(name = "add", sortOptions = false, showDefaultValues = true, mixinStandardHelpOptions = false, header = "Add a Quarkus extension registry", description = "%n"
@@ -30,7 +31,6 @@ public Integer call() throws Exception {
             existingConfig = Files.exists(configYaml);
         }
 
-        registryClient.refreshRegistryCache(output);
         final RegistriesConfig.Mutable config;
         if (configYaml != null && !existingConfig) {
             // we're creating a new configuration for a new file
@@ -38,6 +38,7 @@ public Integer call() throws Exception {
         } else {
             config = registryClient.resolveConfig().mutable();
         }
+        registryClient.refreshRegistryCache(output);
 
         boolean persist = false;
         for (String registryId : registryIds) {
@@ -45,6 +46,10 @@ public Integer call() throws Exception {
         }
 
         if (persist) {
+            output.printText("Configured registries:");
+            for (RegistryConfig rc : config.getRegistries()) {
+                output.printText("- " + rc.getId());
+            }
             if (configYaml != null) {
                 config.persist(configYaml);
             } else {
diff --git a/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java b/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java
index 27b27916167..b98aa196299 100644
--- a/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java
+++ b/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java
@@ -7,6 +7,7 @@
 
 import io.quarkus.cli.registry.BaseRegistryCommand;
 import io.quarkus.registry.config.RegistriesConfig;
+import io.quarkus.registry.config.RegistryConfig;
 import picocli.CommandLine;
 
 @CommandLine.Command(name = "remove", sortOptions = false, showDefaultValues = true, mixinStandardHelpOptions = false, header = "Remove a Quarkus extension registry", description = "%n"
@@ -31,18 +32,13 @@ public Integer call() throws Exception {
         }
 
         final RegistriesConfig.Mutable config;
-        if (existingConfig) {
-            registryClient.refreshRegistryCache(output);
-            config = registryClient.resolveConfig().mutable();
-            if (config.getSource().getFilePath() == null) {
-                output.error("Can only modify file-based configuration. Config source is " + config.getSource().describe());
-                return CommandLine.ExitCode.SOFTWARE;
-            }
+        if (configYaml != null && !existingConfig) {
+            // we're creating a new configuration for a new file
+            config = RegistriesConfig.builder();
         } else {
-            output.error("Can only remove registries from an existing configuration. The specified config file does not exist: "
-                    + configYaml);
-            return CommandLine.ExitCode.SOFTWARE;
+            config = registryClient.resolveConfig().mutable();
         }
+        registryClient.refreshRegistryCache(output);
 
         boolean persist = false;
         for (String registryId : registryIds) {
@@ -50,7 +46,15 @@ public Integer call() throws Exception {
         }
 
         if (persist) {
-            config.persist();
+            output.printText("Configured registries:");
+            for (RegistryConfig rc : config.getRegistries()) {
+                output.printText("- " + rc.getId());
+            }
+            if (configYaml != null) {
+                config.persist(configYaml);
+            } else {
+                config.persist();
+            }
         }
         return CommandLine.ExitCode.OK;
     }
diff --git a/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java b/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java
index 402dcc83643..27047474844 100644
--- a/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java
+++ b/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java
@@ -12,7 +12,6 @@
 import picocli.CommandLine;
 import picocli.CommandLine.Help.ColorScheme;
 import picocli.CommandLine.Model.CommandSpec;
-import picocli.CommandLine.Spec;
 
 public class OutputOptionMixin implements MessageWriter {
 
@@ -83,7 +82,7 @@ public boolean isAnsiEnabled() {
         return CommandLine.Help.Ansi.AUTO.enabled();
     }
 
-    public void printText(String[] text) {
+    public void printText(String... text) {
         for (String line : text) {
             out().println(colorScheme().ansi().new Text(line, colorScheme()));
         }