Update Usage messages to conform to new Usage message contributor guidelines (#3180)

This commit is contained in:
pajlada 2021-08-21 14:41:06 +02:00 committed by GitHub
parent ad4a0c28d1
commit fe8aa33980
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 10 deletions

View file

@ -215,3 +215,28 @@ Keep the element on the stack if possible. If you need a pointer or have complex
- Use the [object tree](https://doc.qt.io/qt-5/objecttrees.html#) to manage lifetimes where possible. Objects are destroyed when their parent object is destroyed. - Use the [object tree](https://doc.qt.io/qt-5/objecttrees.html#) to manage lifetimes where possible. Objects are destroyed when their parent object is destroyed.
- If you have to explicitly delete an object use `variable->deleteLater()` instead of `delete variable`. This ensures that it will be deleted on the correct thread. - If you have to explicitly delete an object use `variable->deleteLater()` instead of `delete variable`. This ensures that it will be deleted on the correct thread.
- If an object doesn't have a parent, consider using `std::unique_ptr<Type, DeleteLater>` with `DeleteLater` from "src/common/Common.hpp". This will call `deleteLater()` on the pointer once it goes out of scope, or the object is destroyed. - If an object doesn't have a parent, consider using `std::unique_ptr<Type, DeleteLater>` with `DeleteLater` from "src/common/Common.hpp". This will call `deleteLater()` on the pointer once it goes out of scope, or the object is destroyed.
## Conventions
#### Usage strings
When informing the user about how a command is supposed to be used, we aim to follow [this standard](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html) where possible.
- Square brackets are reserved for `[optional arguments]`.
- Angle brackets are reserved for `<required arguments>`.
- The word _Usage_ should be capitalized and must be followed by a colon.
- If the usage deserves a description, put a dot after all parameters and explain it briefly.
##### Good
- `Usage: /block <user>`
- `Usage: /unblock <user>. Unblocks a user.`
- `Usage: /streamlink <channel>`
- `Usage: /usercard <user> [channel]`
##### Bad
- `Usage /streamlink <channel>` - Missing colon after _Usage_.
- `usage: /streamlink <channel>` - _Usage_ must be capitalized.
- `Usage: /streamlink channel` - The required argument `channel` must be wrapped in angle brackets.
- `Usage: /streamlink <channel>.` - Don't put a dot after usage if it's not followed by a description.

View file

@ -296,7 +296,7 @@ void CommandController::initialize(Settings &, Paths &paths)
auto blockLambda = [](const auto &words, auto channel) { auto blockLambda = [](const auto &words, auto channel) {
if (words.size() < 2) if (words.size() < 2)
{ {
channel->addMessage(makeSystemMessage("Usage: /block [user]")); channel->addMessage(makeSystemMessage("Usage: /block <user>"));
return ""; return "";
} }
@ -341,7 +341,7 @@ void CommandController::initialize(Settings &, Paths &paths)
auto unblockLambda = [](const auto &words, auto channel) { auto unblockLambda = [](const auto &words, auto channel) {
if (words.size() < 2) if (words.size() < 2)
{ {
channel->addMessage(makeSystemMessage("Usage: /unblock [user]")); channel->addMessage(makeSystemMessage("Usage: /unblock <user>"));
return ""; return "";
} }
@ -455,7 +455,7 @@ void CommandController::initialize(Settings &, Paths &paths)
if (words.size() < 2) if (words.size() < 2)
{ {
channel->addMessage( channel->addMessage(
makeSystemMessage("Usage /user [user] (channel)")); makeSystemMessage("Usage: /user <user> [channel]"));
return ""; return "";
} }
QString userName = words[1]; QString userName = words[1];
@ -625,7 +625,7 @@ void CommandController::initialize(Settings &, Paths &paths)
(!channel->isTwitchChannel() || channel->isEmpty())) (!channel->isTwitchChannel() || channel->isEmpty()))
{ {
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(
"Usage: /streamlink [channel]. You can also use the " "Usage: /streamlink <channel>. You can also use the "
"command without arguments in any Twitch channel to open " "command without arguments in any Twitch channel to open "
"it in streamlink.")); "it in streamlink."));
return ""; return "";
@ -646,7 +646,7 @@ void CommandController::initialize(Settings &, Paths &paths)
(!channel->isTwitchChannel() || channel->isEmpty())) (!channel->isTwitchChannel() || channel->isEmpty()))
{ {
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(
"Usage: /popout [channel]. You can also use the command " "Usage: /popout <channel>. You can also use the command "
"without arguments in any Twitch channel to open its " "without arguments in any Twitch channel to open its "
"popout chat.")); "popout chat."));
return ""; return "";
@ -673,7 +673,7 @@ void CommandController::initialize(Settings &, Paths &paths)
if (words.size() < 2) if (words.size() < 2)
{ {
channel->addMessage( channel->addMessage(
makeSystemMessage("Usage: /settitle <stream title>.")); makeSystemMessage("Usage: /settitle <stream title>"));
return ""; return "";
} }
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
@ -704,7 +704,7 @@ void CommandController::initialize(Settings &, Paths &paths)
if (words.size() < 2) if (words.size() < 2)
{ {
channel->addMessage( channel->addMessage(
makeSystemMessage("Usage: /setgame <stream game>.")); makeSystemMessage("Usage: /setgame <stream game>"));
return ""; return "";
} }
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
@ -769,7 +769,7 @@ void CommandController::initialize(Settings &, Paths &paths)
const ChannelPtr channel) { const ChannelPtr channel) {
if (words.size() < 2) if (words.size() < 2)
{ {
channel->addMessage(makeSystemMessage("Usage: /openurl <URL>.")); channel->addMessage(makeSystemMessage("Usage: /openurl <URL>"));
return ""; return "";
} }

View file

@ -810,8 +810,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
if (tags == "bad_delete_message_error" || tags == "usage_delete") if (tags == "bad_delete_message_error" || tags == "usage_delete")
{ {
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(
"Usage: \"/delete <msg-id>\" - can't take more " "Usage: /delete <msg-id>. Can't take more than one argument"));
"than one argument"));
} }
else if (tags == "host_on" || tags == "host_target_went_offline") else if (tags == "host_on" || tags == "host_target_went_offline")
{ {