-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Integrate mason_logger for improved logging and user prompts #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Integrate mason_logger for improved logging and user prompts #23
Conversation
lib/commands/create_command.dart
Outdated
|
||
final name = getString( | ||
isInteractive: interactive, | ||
logger: logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we standardize the logger to be the first parameter?
lib/commands/create_command.dart
Outdated
import 'package:process_run/process_run.dart'; | ||
|
||
Future<void> createCommand(ArgResults command) async { | ||
Future<void> createCommand(ArgResults command, Logger logger) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a followup, I would envision we creating some class that wraps the ArgResults and Logger to pass around as a unit, and then the "utils" methods would live on this class as well
something like "CLI context", not sure what is a good name
but as I said - this is def a followup!
CC: @luanpotter @spydon Future<void> mainCommand(List<String> args) async {
await FlameVersionManager.init();
final runner = IgniteCommandRunner(
logger: Logger(),
flameVersionManager: FlameVersionManager.singleton,
);
exit((await runner.run(args)).code);
} class IgniteCommandRunner extends CommandRunner<ExitCode> {
IgniteCommandRunner({
required Logger logger,
required FlameVersionManager flameVersionManager,
}) : _logger = logger,
super(_name, _description) {
addCommand(
CreateCommand(
logger: logger,
flameVersionManager: flameVersionManager,
),
);
argParser.addFlag(
'version',
abbr: 'v',
help: 'Print the current version.',
negatable: false,
);
}
} class CreateCommand extends Command<ExitCode> {
CreateCommand({
required Logger logger,
required FlameVersionManager flameVersionManager,
}) : _logger = logger,
_manager = flameVersionManager,
super() {
final packages = flameVersionManager.versions;
final flameVersions = packages[Package.flame]!;
argParser
..addFlag(
'interactive',
abbr: 'i',
help: 'Whether to run in interactive mode or not.',
defaultsTo: true,
)
..addOption(
'name',
help: 'The name of your game (valid dart identifier).',
)
..addOption(
'org',
help: 'The org name, in reverse domain notation '
'(package name/bundle identifier).',
)
..addFlag(
'create-folder',
abbr: 'f',
help: 'If you want to create a new folder on the current location with '
"the project name or if you are already on the new project's folder.",
)
..addOption(
'template',
help: 'What Flame template you would like to use for your new project',
allowed: ['simple', 'example'],
)
..addOption(
'flame-version',
help: 'What Flame version you would like to use.',
allowed: [
...flameVersions.versions.take(5),
'...',
flameVersions.versions.last,
],
)
..addMultiOption(
'extra-packages',
help: 'Which packages to use',
allowed: packages.keys.map((e) => e.name).toList(),
);
}
} |
What would the differences be? The code definitely looks cleaner. |
The |
If I'm understanding it correctly, this is quite similar to what we have, just uses the we would still need to keep all the code for the interactive mode, and the functionality would be exactly the same? if so - definitely, let's do it! |
maybe we can also create an
similar to my idea above? then all commands can receive the same parameter and we can easily add more injected helpers later on w/o modifying signatures |
Yes! I will add something that can encapsulate those (and future) objects |
analysis_options.yaml
Outdated
linter: | ||
rules: | ||
avoid_print: false # since it is a CLI application | ||
avoid_print: true # should always use a Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can just remove the override - it will be true by default :)
lib/ignite_commmand_runner.dart
Outdated
} | ||
} | ||
|
||
static const _description = 'Ignite your projects with flame; ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static const _description = 'Ignite your projects with flame; ' | |
static const _description = 'Ignite your projects with Flame; ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
I am wrapping up some tests now that I am at a more comfortable spot for how the APIs are setup. The |
I haven't forgot about this 😅. I working on a feature for felangel/mason#1550 first then going to integrate that new feature here to bring it back to parity |
@Luckey-Elijah is this something I could help out with? is it blocked on a mason PR that I can help expedite, or require some implementation there that we can figure out, or can we merge an initial version and then followup with @felangel later? happy to help with whatever is needed to get this through, such a huge improvement! |
I tried to decrease the imprint of any API changes (specifically, those in utils.dart). But I think it would be ideal if we could also use the other APIs of mason_logger for writing to stdout/stderr (err/info/detail/etc) methods.
should fix #12 and #14