@forge/cli

12.9.0-next.1712.9.0-next.18-experimental-f76634b
out/command-line/command.js
~out/command-line/command.jsModified
+19−1
Index: package/out/command-line/command.js
===================================================================
--- package/out/command-line/command.js
+++ package/out/command-line/command.js
@@ -1,7 +1,7 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.environmentPrecondition = exports.validateContext = exports.getAutocompleteConfig = exports.Command = exports.WrapperError = void 0;
+exports.environmentPrecondition = exports.validateShardContext = exports.validateContext = exports.getAutocompleteConfig = exports.Command = exports.WrapperError = void 0;
 const tslib_1 = require("tslib");
 const commander_1 = tslib_1.__importStar(require("commander"));
 const semver_1 = tslib_1.__importDefault(require("semver"));
 const cli_shared_1 = require("@forge/cli-shared");
@@ -200,8 +200,15 @@
             const { site, product } = last(args);
             return validateContext({ supportedProductsService, site, product });
         });
     }
+    shardOption() {
+        return this.option('--shard <shard>', cli_shared_1.Text.optionShard.desc).precondition(async (...args) => {
+            const { shard } = last(args);
+            const validatedShard = validateShardContext(shard);
+            return { shard: validatedShard };
+        });
+    }
     jsonOption() {
         return this.option('--json', cli_shared_1.Text.optionJson, false);
     }
     requireNoAuthentication() {
@@ -453,8 +460,19 @@
     }
     return { site: maybeSiteUrl, product: maybeSupportedProduct };
 }
 exports.validateContext = validateContext;
+function validateShardContext(shard) {
+    if (shard) {
+        const [id, region, ...rest] = shard.split(':');
+        if (!id || !region || rest.length > 0) {
+            throw new cli_shared_1.ValidationError(cli_shared_1.Text.optionShard.incorrectFormat);
+        }
+        return shard;
+    }
+    return undefined;
+}
+exports.validateShardContext = validateShardContext;
 function environmentPrecondition(key, environmentController) {
     return async (...args) => {
         const lastArgs = last(args);
         const environmentArg = lastArgs[key];