Skip to content

Commit 4df5490

Browse files
committed
Add --environment option
1 parent 080f15e commit 4df5490

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

bin/flutterflow_cli.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,32 @@ void main(List<String> args) async {
1414
final project = parsedArguments.command!['project'] ??
1515
Platform.environment['FLUTTERFLOW_PROJECT'];
1616

17+
if (parsedArguments['endpoint'] != null &&
18+
parsedArguments['environment'] != null) {
19+
stderr.write(
20+
'Only one of --endpoint and --environment options can be set.\n');
21+
exit(1);
22+
}
23+
1724
if (token?.isEmpty ?? true) {
1825
stderr.write(
1926
'Either --token option or FLUTTERFLOW_API_TOKEN environment variable must be set.\n');
2027
exit(1);
2128
}
2229

30+
late String endpoint;
31+
if (parsedArguments['endpoint'] != null) {
32+
endpoint = parsedArguments['endpoint'];
33+
} else if (parsedArguments['environment'] != null) {
34+
endpoint =
35+
"https://api-${parsedArguments['environment']}.flutterflow.io/v1";
36+
} else {
37+
endpoint = kDefaultEndpoint;
38+
}
39+
2340
await exportCode(
2441
token: token,
25-
endpoint: parsedArguments['endpoint'] ?? kDefaultEndpoint,
42+
endpoint: endpoint,
2643
projectId: project,
2744
destinationPath: parsedArguments.command!['dest'],
2845
includeAssets: parsedArguments.command!['include-assets'],
@@ -66,6 +83,7 @@ ArgResults _parseArgs(List<String> args) {
6683

6784
final parser = ArgParser()
6885
..addOption('endpoint', abbr: 'e', help: 'Endpoint', hide: true)
86+
..addOption('environment', help: 'Environment', hide: true)
6987
..addOption('token', abbr: 't', help: 'API Token')
7088
..addFlag('help', negatable: false, abbr: 'h', help: 'Help')
7189
..addCommand('export-code', exportCodeCommandParser);

0 commit comments

Comments
 (0)