refactor: /command hints add tooltips, test for missing hints, script to generate glue code, hints for dm, create, clearcache, discardsession
parent
adba445c33
commit
3c14cbe017
@ -0,0 +1,46 @@
|
||||
// This file is auto-generated using scripts/generate_command_hints_glue.sh.
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
String commandHint(L10n l10n, String command) {
|
||||
switch (command) {
|
||||
case "ban":
|
||||
return l10n.commandHint_ban;
|
||||
case "clearcache":
|
||||
return l10n.commandHint_clearcache;
|
||||
case "create":
|
||||
return l10n.commandHint_create;
|
||||
case "discardsession":
|
||||
return l10n.commandHint_discardsession;
|
||||
case "dm":
|
||||
return l10n.commandHint_dm;
|
||||
case "html":
|
||||
return l10n.commandHint_html;
|
||||
case "invite":
|
||||
return l10n.commandHint_invite;
|
||||
case "join":
|
||||
return l10n.commandHint_join;
|
||||
case "kick":
|
||||
return l10n.commandHint_kick;
|
||||
case "leave":
|
||||
return l10n.commandHint_leave;
|
||||
case "me":
|
||||
return l10n.commandHint_me;
|
||||
case "myroomavatar":
|
||||
return l10n.commandHint_myroomavatar;
|
||||
case "myroomnick":
|
||||
return l10n.commandHint_myroomnick;
|
||||
case "op":
|
||||
return l10n.commandHint_op;
|
||||
case "plain":
|
||||
return l10n.commandHint_plain;
|
||||
case "react":
|
||||
return l10n.commandHint_react;
|
||||
case "send":
|
||||
return l10n.commandHint_send;
|
||||
case "unban":
|
||||
return l10n.commandHint_unban;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# Generates some glue code for translation of /command hints.
|
||||
|
||||
# How to use this:
|
||||
# - Add any new hints to assets/l10n/intl_en.arb
|
||||
# They must be of the form commandHint_<command> with <command> in lowercase.
|
||||
# - Run this script to regenerate the glue code
|
||||
# - Run flutter test to see if you did everything right
|
||||
|
||||
# Looking to add descriptions for a new command, but don't know what it does?
|
||||
# It is likely defined here (in registerDefaultCommands()):
|
||||
# https://gitlab.com/famedly/company/frontend/famedlysdk/-/blob/main/lib/src/utils/commands_extension.dart
|
||||
|
||||
echo "\
|
||||
// This file is auto-generated using scripts/generate_command_hints_glue.sh.
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
String commandHint(L10n l10n, String command) {
|
||||
switch (command) {
|
||||
$(sed -n \
|
||||
's/[[:blank:]]*\"\(commandHint_\([[:lower:]]*\)\)\".*/ case "\2":\
|
||||
return l10n.\1;/p' \
|
||||
assets/l10n/intl_en.arb
|
||||
)
|
||||
default:
|
||||
return \"\";
|
||||
}
|
||||
}\
|
||||
" > lib/pages/chat/command_hints.dart
|
@ -0,0 +1,23 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'utils/test_client.dart';
|
||||
|
||||
void main() async {
|
||||
test('Check for missing /command hints', () async {
|
||||
final translated =
|
||||
jsonDecode(File('assets/l10n/intl_en.arb').readAsStringSync())
|
||||
.keys
|
||||
.where((String k) => k.startsWith('commandHint_'))
|
||||
.map((k) => k.replaceFirst('commandHint_', ''));
|
||||
final commands = (await prepareTestClient()).commands.keys;
|
||||
final missing = commands.where((c) => !translated.contains(c)).toList();
|
||||
|
||||
expect(0, missing.length,
|
||||
reason: 'missing hints for ' +
|
||||
missing.toString() +
|
||||
'\nAdding hints? See scripts/generate_command_hints_glue.sh');
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue