Skip to content

Commit b0104d9

Browse files
authored
Add FLUTTERFLOW_PROJECT env variable option (#11)
1 parent 21bdd61 commit b0104d9

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FlutterFlow CLI
22

3-
FlutterFlow CLI client. Currently it only allows exporting code from FlutterFlow.
3+
FlutterFlow CLI client: download code from your FlutterFlow project to your device for local running or deployment.
44

55
## API Token
66

@@ -14,17 +14,18 @@ API access is available only to users with active subscriptions. Visit https://a
1414

1515
`flutterflow export-code --project <project id> --dest <output folder> --[no-]include-assets --token <token> --[no-]fix --[no]-parent-folder`
1616

17-
Alternatively, instead of passing `--token` you can set `FLUTTERFLOW_API_TOKEN` environment variable.
17+
* Instead of passing `--token` you can set `FLUTTERFLOW_API_TOKEN` environment variable.
18+
* Instead of passing `--project` you can set `FLUTTERFLOW_PROJECT` environment variable.
1819

1920
## Flags
2021

2122
| Flag | Abbreviation | Usage |
2223
| ----------- | ----------- | ----------- |
23-
| `--project` | `-p` | [Required] Project ID |
24-
| `--token` | `-t` | [Required or environment variable] API Token |
25-
| `--dest` | `-d` | [Optional] Output folder |
26-
| `--[no-]include-assets` | None | [Optional] Whether to include media assets. Defaults to `false` |
27-
| `--branch-name` | `-b` | [Optional] Which branch to download. Defaults to `main` |
24+
| `--project` | `-p` | [Required or environment variable] Project ID. |
25+
| `--token` | `-t` | [Required or environment variable] API Token. |
26+
| `--dest` | `-d` | [Optional] Output folder. Defaults to the current directory if none is specified. |
27+
| `--[no-]include-assets` | None | [Optional] Whether to include media assets. Defaults to `false`. |
28+
| `--branch-name` | `-b` | [Optional] Which branch to download. Defaults to `main`. |
2829
| `--[no-]fix` | None | [Optional] Whether to run `dart fix` on the downloaded code. Defaults to `false`. |
2930
| `--[no-]parent-folder` | None | [Optional] Whether to download code into a project-named sub-folder. If true, downloads all project files directly to the specified directory. Defaults to `true`. |
3031

bin/flutterflow_cli.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ void main(List<String> args) async {
1515
final token =
1616
parsedArguments['token'] ?? Platform.environment['FLUTTERFLOW_API_TOKEN'];
1717

18+
final project = parsedArguments.command!['project'] ??
19+
Platform.environment['FLUTTERFLOW_PROJECT'];
20+
1821
if (token?.isEmpty ?? true) {
1922
stderr.write(
2023
'Either --token option or FLUTTERFLOW_API_TOKEN environment variable must be set.\n');
@@ -24,7 +27,7 @@ void main(List<String> args) async {
2427
await _exportCode(
2528
token: token,
2629
endpoint: parsedArguments['endpoint'] ?? kDefaultEndpoint,
27-
projectId: parsedArguments.command!['project'],
30+
projectId: project,
2831
destinationPath: parsedArguments.command!['dest'],
2932
includeAssets: parsedArguments.command!['include-assets'],
3033
branchName: parsedArguments.command!['branch-name'],
@@ -98,10 +101,10 @@ ArgResults _parseArgs(List<String> args) {
98101

99102
if (parsed.command!['project'] == null ||
100103
parsed.command!['project'].isEmpty) {
101-
stderr.write('Option --project is required\n');
104+
stderr.write(
105+
'Either --project option or FLUTTERFLOW_PROJECT environment variable must be set.\n');
102106
exit(1);
103107
}
104-
105108
return parsed;
106109
}
107110

0 commit comments

Comments
 (0)