liveShellCommands top-level property
List<LiveShellCommand>
get
liveShellCommands
The commands metro live lists in help and completes with Tab.
Implementation
List<LiveShellCommand> get liveShellCommands {
List<String> optionsOf(NyCustomCommand Function(List<String>) create) {
final String usage = create(const []).builder(CommandBuilder()).usage;
return {
for (final RegExpMatch match in RegExp(
r'--(?:\[no-\])?([a-z][a-z0-9-]*)',
).allMatches(usage))
'--${match.group(1)}',
}.toList();
}
LiveShellCommand builtIn(String name, String usage, String description) => (
name: name,
usage: usage,
description: description,
options: optionsOf(_liveShellBuiltIns[name]!),
);
return [
(
name: 'devices',
usage: 'devices',
description: 'List the running apps, numbered for use',
options: const [],
),
(
name: 'use',
usage: 'use <#|name|all>',
description: 'Run commands on one app, or on all of them',
options: const [],
),
builtIn('status', 'status', 'Show the page, stack, locale and session'),
builtIn(
'seed',
'seed [name|file]',
'Run seeders or load a snapshot, or list them',
),
builtIn(
'seed:rollback',
'seed:rollback <name>',
'Roll seeders back with down()',
),
builtIn(
'export',
'export [name]',
'Save the app\'s storage as a seeder, or with --to as a file',
),
builtIn('reload', 'reload', 'Hot reload the app'),
builtIn('restart', 'restart', 'Hot restart the app'),
for (final MapEntry<String, LiveRunAction> action in liveRunActions.entries)
(
name: action.key,
usage: action.key,
description: action.value.description,
options: optionsOf(action.value.create),
),
(
name: 'help',
usage: 'help [command]',
description: 'List the commands, or show one command\'s options',
options: const [],
),
(
name: 'exit',
usage: 'exit',
description: 'Leave the shell (Ctrl+D does too)',
options: const [],
),
];
}