Permalink
Browse files

feature: -k cmdline option added, shows available keys for site.yaml

  • Loading branch information...
MikeMitterer committed Dec 7, 2016
1 parent 5529372 commit 8decde6544595273513f3dcca8f12adcd0a9e5fd
Showing with 20 additions and 6 deletions.
  1. +5 −0 lib/src/Application.dart
  2. +12 −4 lib/src/Config.dart
  3. +3 −0 lib/src/Options.dart
  4. +0 −2 samples/simple/web/main.dart
View
@@ -37,6 +37,11 @@ class Application {
return;
}
if (argResults.wasParsed(Options._ARG_SITE_KEYS)) {
config.printSiteKeys();
return;
}
bool foundOptionToWorkWith = false;
if (argResults.wasParsed(Options._ARG_INIT)) {
View
@@ -209,18 +209,19 @@ class Config {
return length;
}
final int maxKeyLeght = getMaxKeyLength();
final int maxKeyLength = getMaxKeyLength();
String prepareKey(final String key) {
if(!key.isEmpty) {
return "${key[0].toUpperCase()}${key.substring(1)}:".padRight(maxKeyLeght + 1);
return "${key[0].toUpperCase()}${key.substring(1)}:".padRight(maxKeyLength + 1);
} else {
// this is only the case if setting is "sass_path..."
return key.padRight(maxKeyLeght + 1);
return key.padRight(maxKeyLength + 1);
}
}
print("Settings:");
//print(" ${'Name'.padRight(maxKeyLeght)} ${'Value'.padRight(25)} ${'Key (site.yaml)'}");
settings.forEach((final String key,final value) {
if(key.toLowerCase().startsWith("sass_path") && sasspath.isNotEmpty) {
final List<String> segments = value.split(_SEARCH_PATH_SEPARATOR);
@@ -230,12 +231,19 @@ class Config {
});
} else {
print(" ${prepareKey(key)} $value");
print(" ${prepareKey(key)} ${value.padRight(25)}");
}
});
}
void printSiteKeys() {
print("Keys for ${configfile}:");
_settings.forEach((final String key,final dynamic value) {
print(" ${(key + ':').padRight(20)} $value");
});
}
// -- private -------------------------------------------------------------
void _overwriteSettingsWithArgResults() {
View
@@ -7,6 +7,7 @@ class Options {
static const _ARG_HELP = 'help';
static const _ARG_LOGLEVEL = 'loglevel';
static const _ARG_SETTINGS = 'settings';
static const _ARG_SITE_KEYS = 'keys';
static const _ARG_GENERATE = 'generate';
static const _ARG_GENERATE_CSS = 'generatecss';
static const _ARG_SERVE = 'serve';
@@ -55,6 +56,8 @@ class Options {
..addFlag(_ARG_SETTINGS, abbr: 's', negatable: false, help: "Prints settings")
..addFlag(_ARG_SITE_KEYS, abbr: 'k', negatable: false, help: "Shows keys for site.yaml")
..addFlag(_ARG_HELP, abbr: 'h', negatable: false, help: "Shows this message")
..addFlag(_ARG_GENERATE, abbr: 'g', negatable: false, help: "Generate site")
@@ -1,5 +1,3 @@
import 'dart:html' as html;
import 'package:logging/logging.dart';
import 'package:console_log_handler/console_log_handler.dart';

0 comments on commit 8decde6

Please sign in to comment.