[cli] add command to set mesh-local prefix (#7663)

Also add an expect test for getting/setting mesh-local prefix.
diff --git a/src/cli/README.md b/src/cli/README.md
index b2c4056..1dd92e4 100644
--- a/src/cli/README.md
+++ b/src/cli/README.md
@@ -2177,6 +2177,15 @@
 Done
 ```
 
+### prefix meshlocal <prefix>
+
+Set the mesh local prefix.
+
+```bash
+> prefix meshlocal fdde:ad00:beef:0::/64
+Done
+```
+
 ### prefix remove \<prefix\>
 
 Invalidate a prefix in the Network Data.
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index 8ebfa47..ef5376f 100644
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -3564,7 +3564,19 @@
     }
     else if (aArgs[0] == "meshlocal")
     {
-        OutputIp6PrefixLine(*otThreadGetMeshLocalPrefix(GetInstancePtr()));
+        if (aArgs[1].IsEmpty())
+        {
+            OutputIp6PrefixLine(*otThreadGetMeshLocalPrefix(GetInstancePtr()));
+        }
+        else
+        {
+            otIp6Prefix prefix;
+
+            SuccessOrExit(error = aArgs[1].ParseAsIp6Prefix(prefix));
+            VerifyOrExit(prefix.mLength == OT_IP6_PREFIX_BITSIZE, error = OT_ERROR_INVALID_ARGS);
+            error =
+                otThreadSetMeshLocalPrefix(GetInstancePtr(), reinterpret_cast<otMeshLocalPrefix *>(&prefix.mPrefix));
+        }
     }
     else
     {
diff --git a/tests/scripts/expect/cli-misc.exp b/tests/scripts/expect/cli-misc.exp
index 89da807..8b8b4d5 100755
--- a/tests/scripts/expect/cli-misc.exp
+++ b/tests/scripts/expect/cli-misc.exp
@@ -180,6 +180,13 @@
 send "ba state\n"
 expect "Done"
 
+send "prefix meshlocal fd00:dead:beef:cafe::/96\n"
+expect_line "Error 7: InvalidArgs"
+send "prefix meshlocal fd00:dead:beef:cafe::/64\n"
+expect_line "Done"
+send "prefix meshlocal\n"
+expect_line "fd00:dead:beef:cafe::/64"
+
 send "invalidcommand\n"
 expect_line "Error 35: InvalidCommand"