Skip to content

Commit

Permalink
Fix prefix not printed when nothing is printed
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Sep 30, 2024
1 parent 49102e3 commit f8f793c
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/consoler/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
3 changes: 3 additions & 0 deletions packages/consoler/example/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
2 changes: 2 additions & 0 deletions packages/consoler/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.
30 changes: 30 additions & 0 deletions packages/consoler/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
15 changes: 15 additions & 0 deletions packages/consoler/example/bin/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:consoler/consoler.dart';
import 'package:example/example.dart';

Future<void> main(List<String> arguments) async {
final consoler = Consoler(
defaultProgramConfig:
DefaultProgramConfiguration(description: 'Consoler example'),
);
consoler.registerProgram('nothing', NothingProgram());
consoler.run();
for (var i = 10; i >= 0; i--) {
consoler.print('Countdown: $i');
await Future.delayed(Duration(seconds: 1));
}
}
9 changes: 9 additions & 0 deletions packages/consoler/example/lib/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:consoler/consoler.dart';

class NothingProgram extends ConsoleProgram {
@override
void run(String label, List<String> args) {}

@override
String? getDescription() => null;
}
18 changes: 18 additions & 0 deletions packages/consoler/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: example
description: A sample command-line application.
version: 1.0.0
publish_to: none
# repository: https://github.com/my_org/my_repo

environment:
sdk: ^3.5.3

# Add regular dependencies here.
dependencies:
consoler:
path: ../
# path: ^1.8.0

dev_dependencies:
lints: ^4.0.0
test: ^1.24.0
1 change: 1 addition & 0 deletions packages/consoler/lib/src/consoler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ final class Consoler<T extends ConsoleProgram> {
final command = splitted.firstOrNull;
(_programs[command] ?? _programs[null])
?.run(command ?? '', splitted.isEmpty ? const [] : splitted.sublist(1));
sendPrefix();
}
}

0 comments on commit f8f793c

Please sign in to comment.