docs & readme

This commit is contained in:
Chen Asraf
2019-12-23 22:01:01 +02:00
parent 2c2d464260
commit 9f5d3cb394
4 changed files with 44 additions and 7 deletions

View File

@@ -6,4 +6,24 @@ This allows you to easily create components for your projects, be it similar ske
You can install this package either globally or locally in your package and use the command line tools for configs.
pub global activate file_scaffold
You can access the command-line usage args using `pub global run file_scaffold -h`:
-n, --name Name of this scaffold, to be used in folder name (if
--create-subfolder is used) and file templates.
-o, --output-dir Directory to output the template files to. They will
maintain their original directory structure.
-C, --[no-]create-subfolder Create subfolder at the output directory, using the
scaffold's name.
-t, --templates=<path/to/templates/**.json> List of templates to get files from. You may supply a
glob string to include only files using that pattern.
-l, --locals=<key="value" [, ...]> List of key-value mappings of locals to pass to the
scaffold.
-h, --help Display this help message.

View File

@@ -5,7 +5,7 @@ void main(List<String> args) {
var res = FileScaffoldConfig.argParser.parse(args);
if (res['help']) {
print(FileScaffoldConfig.argParser.usage);
FileScaffoldConfig.printHelp();
exit(0);
}
try {
@@ -14,6 +14,6 @@ void main(List<String> args) {
} on ArgumentError {
print('Problem parsing the input arguments.');
print(FileScaffoldConfig.argParser.usage);
exit(0);
exit(1);
}
}

View File

@@ -122,13 +122,29 @@ class FileScaffoldConfig {
}
static void printHelp() {
print('File Scaffolding from a directory structure of any templates with replaceable-tokens');
print('for generating files from simple parameters.\n');
print('Usage:');
print(' When installed globally:\n');
print(' pub global run file_scaffold -n name [...flags]');
print('\nOptions:\n');
print(argParser.usage);
}
static ArgParser _createArgsParser() {
var argParser = ArgParser();
argParser.addOption('name', abbr: 'n');
argParser.addOption('output-dir', abbr: 'o');
var argParser = ArgParser(usageLineLength: 100);
argParser.addOption(
'name',
abbr: 'n',
help:
'Name of this scaffold, to be used in folder name (if --create-subfolder is used) and file templates.',
);
argParser.addOption(
'output-dir',
abbr: 'o',
help:
'Directory to output the template files to. They will maintain their original directory structure.',
);
argParser.addFlag(
'create-subfolder',
abbr: 'C',
@@ -151,7 +167,7 @@ class FileScaffoldConfig {
argParser.addFlag(
'help',
abbr: 'h',
help: 'This usage text.',
help: 'Display this help message.',
negatable: false,
);
return argParser;

View File

@@ -1,3 +1,4 @@
library file_scaffold;
import 'dart:io';
import 'package:glob/glob.dart';
import 'package:file_scaffold/config.dart';