8000 Fix linting issues and warnings by luanpotter · Pull Request #5 · thosakwe/prompts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Fix linting issues and warnings #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions lib/prompts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ String get(String message,
validate = (s) => s.trim().isEmpty || oldValidate(s);
}

var prefix = "?";
var prefix = '?';
var code = cyan;
var currentChevron = '\u00BB';
var oldEchoMode = stdin.echoMode;

void writeIt() {
var msg = color
? (code.wrap(prefix) + " " + wrapWith(message, [darkGray, styleBold]))
? '${code.wrap(prefix)} ${wrapWith(message, [darkGray, styleBold])}'
: message;
stdout.write(msg);
if (defaultsTo != null) stdout.write(' ($defaultsTo)');
Expand Down Expand Up @@ -144,7 +144,7 @@ String get(String message,
return out;
} else {
code = red;
prefix = "\u2717";
prefix = '\u2717';
if (ansiOutputEnabled) stdout.add([$esc, $F]);

// Clear the line.
Expand Down Expand Up @@ -187,9 +187,11 @@ bool getBool(String message,
);
result = result.toLowerCase();

if (result.isEmpty)
if (result.isEmpty) {
return defaultsTo;
else if (result == 'y') return true;
} else if (result == 'y') {
return true;
}
return false;
}

Expand Down Expand Up @@ -318,13 +320,13 @@ T choose<T>(String message, Iterable<T> options,
if (!needsClear) {
needsClear = true;
} else {
for (int i = 0; i < options.length; i++) {
for (var i = 0; i < options.length; i++) {
goUpOneLine();
clearLine();
}
}

for (int i = 0; i < options.length; i++) {
for (var i = 0; i < options.length; i++) {
var key = map.keys.elementAt(i);
var msg = map[key];
AnsiCode code;
Expand Down Expand Up @@ -392,7 +394,7 @@ T choose<T>(String message, Iterable<T> options,
} else {
b.writeln();

for (int i = 0; i < options.length; i++) {
for (var i = 0; i < options.length; i++) {
var key = map.keys.elementAt(i);
var indicator = names != null ? names.elementAt(i) : (i + 1).toString();
b.write('$indicator) ${map[key]}');
Expand All @@ -417,7 +419,7 @@ T choose<T>(String message, Iterable<T> options,
if (s.isEmpty) return defaultsTo != null;
if (map.values.contains(s)) return true;
if (names != null && names.contains(s)) return true;
int i = int.tryParse(s);
final i = int.tryParse(s);
if (i == null) return false;
return i >= 1 && i <= options.length;
},
Expand Down Expand Up @@ -461,7 +463,7 @@ T chooseShorthand<T>(String message, Iterable<T> options,
if (chevron && colon) b.write(':');
b.write(' (');
var firstChars = <String>[], strings = <String>[];
int i = 0;
var i = 0;

for (var option in options) {
var str = option.toString();
Expand Down
0