Repository: Cog-Creators/Red-DiscordBot

Issue:
Allow --prefix to be saved via --edit --no-prompt
# Feature request

<!-- This template is for feature requests. Please fill out the following: -->


#### Select the type of feature you are requesting:

<!-- To check a box, replace the space between the [] with a x -->

- [ ] Cog
- [x] Command
- [ ] API functionality
- [x] CLI? CLI!

#### Describe your requested feature

<!--
Feel free to describe in as much detail as you wish.

If you are requesting a cog to be included in core: 
    - Describe the functionality in as much detail as possible
    - Include the command structure, if possible
    - Please note that unless it's something that should be core functionality,
      we reserve the right to reject your suggestion and point you to our cog 
      board to request it for a third-party cog
      
If you are requesting a command:
    - Include what cog it should be in and a name for the command
    - Describe the intended functionality for the command
    - Note any restrictions on who can use the command or where it can be used

If you are requesting API functionality:
    - Describe what it should do
    - Note whether it is to extend existing functionality or introduce new functionality
   
-->
The command line allows for `--edit --no-prompt` to modify and save the instance name, data path, owner, and token. I would like for it to also be able to save the `--prefix` option(s) as well, as this is one of two required configuration values needed when setting up a bot manually (the other being token).

Thank you!


Discussion:

Resolving patch:
diff --git a/redbot/__main__.py b/redbot/__main__.py
--- a/redbot/__main__.py
+++ b/redbot/__main__.py
@@ -107,6 +107,7 @@ async def edit_instance(red, cli_flags):
     no_prompt = cli_flags.no_prompt
     token = cli_flags.token
     owner = cli_flags.owner
+    prefix = cli_flags.prefix
     old_name = cli_flags.instance_name
     new_name = cli_flags.edit_instance_name
     data_path = cli_flags.edit_data_path
@@ -119,14 +120,20 @@ async def edit_instance(red, cli_flags):
     if new_name is None and confirm_overwrite:
         print("--overwrite-existing-instance can't be used without --edit-instance-name argument")
         sys.exit(1)
-    if no_prompt and all(to_change is None for to_change in (token, owner, new_name, data_path)):
+    if (
+        no_prompt
+        and all(to_change is None for to_change in (token, owner, new_name, data_path))
+        and not prefix
+    ):
         print(
-            "No arguments to edit were provided. Available arguments (check help for more "
-            "information): --edit-instance-name, --edit-data-path, --copy-data, --owner, --token"
+            "No arguments to edit were provided."
+            " Available arguments (check help for more information):"
+            " --edit-instance-name, --edit-data-path, --copy-data, --owner, --token, --prefix"
         )
         sys.exit(1)
 
     await _edit_token(red, token, no_prompt)
+    await _edit_prefix(red, prefix, no_prompt)
     await _edit_owner(red, owner, no_prompt)
 
     data = deepcopy(data_manager.basic_config)
@@ -152,6 +159,26 @@ async def _edit_token(red, token, no_prompt):
         print("Token updated.\n")
 
 
+async def _edit_prefix(red, prefix, no_prompt):
+    if prefix:
+        prefixes = sorted(prefix, reverse=True)
+        await red._config.prefix.set(prefixes)
+    elif not no_prompt and confirm("Would you like to change instance's prefixes?", default=False):
+        print(
+            "Enter the prefixes, separated by a space (please note "
+            "that prefixes containing a space will need to be added with [p]set prefix)"
+        )
+        while True:
+            prefixes = input("> ").strip().split()
+            if not prefixes:
+                print("You need to pass at least one prefix!")
+                continue
+            prefixes = sorted(prefixes, reverse=True)
+            await red._config.prefix.set(prefixes)
+            print("Prefixes updated.\n")
+            break
+
+
 async def _edit_owner(red, owner, no_prompt):
     if owner:
         if not (15 <= len(str(owner)) <= 21):
diff --git a/redbot/core/cli.py b/redbot/core/cli.py
--- a/redbot/core/cli.py
+++ b/redbot/core/cli.py
@@ -90,7 +90,7 @@ def parse_cli_flags(args):
         action="store_true",
         help="Edit the instance. This can be done without console interaction "
         "by passing --no-prompt and arguments that you want to change (available arguments: "
-        "--edit-instance-name, --edit-data-path, --copy-data, --owner, --token).",
+        "--edit-instance-name, --edit-data-path, --copy-data, --owner, --token, --prefix).",
     )
     parser.add_argument(
         "--edit-instance-name",


Test patch: