forked from flutter-view/flutter-view
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·40 lines (36 loc) · 1.16 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
const program = require("commander");
const fs = require("fs");
const watcher = require("./dist/watcher.js");
const _ = require("lodash");
function cli() {
program
.version("2.0.0")
.usage("[options] <directory ...>")
.description(
"Converts html and css templates into Flutter view widget code."
)
.option("-w, --watch", "Watch for changes")
.option(
"-c, --config <file>",
"Optional config file to use",
"flutter-view.json"
)
.parse(process.argv);
// extract the directories to scan
const dir = program.args.length > 0 ? program.args[0] : null;
console.log("flutter-view - flutter template code generator");
if (!dir) {
console.log("Converts html and css templates into Flutter view widget code.");
console.log("- Generates null-safe code. Use pre-2.0 version if you do not want null-safe code -")
console.log("Please pass a directory to scan.");
console.log("flutter-view -h for help.");
return;
}
// get the configuration
const configFileName = program.config;
// start the watching
if (program.watch) console.log("watching for file changes...");
watcher.startWatching(dir, configFileName, program.watch);
}
cli();