-
Notifications
You must be signed in to change notification settings - Fork 283
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
Make help be consistent. #1169
Make help be consistent. #1169
Conversation
Always funny to learn about new commands even after years :D
|
I think this thing might just be broken and maybe should be deleted. I'll ask @vicroms if anyone is running this thing.... |
Review comments on the usage:
|
Clean up needing to make thunks for all help text in command metadata machinery.
…ookup. Resolves this line item first discovered in microsoft#1164
d27369d
to
b64f222
Compare
The force push I just pushed should be no changes, just rebasing off the stuff that was identical to #1165 |
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.
LGTM.
} | ||
|
||
template<class Callback, | ||
std::enable_if_t<std::is_convertible_v<const Callback&, LocalizedString (*)()>, int> = 0> |
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 my own education: why does this use const Callback&
instead of Callback
by value?
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.
I think they are equivalent in this case. I just default to const T&
unless I have a specific reason to do otherwise when writing templates.
Note that even if the callback is Callback callback
rather than const Callback& callback
, the is_convertible_v
still needs to have a &
since we are converting the callback as an lvalue.
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.
(Also it's smashed to a function pointer at constexpr time so there's no runtime difference; given that all the other ctors take references I'd like to leave this as-is because overload resolution that involves overloads that bind a reference vs. overloads that do not makes my brain hurt...)
src/vcpkg/commands.autocomplete.cpp
Outdated
} | ||
} | ||
|
||
// If no public commands match, try intenral commands |
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.
// If no public commands match, try intenral commands | |
// If no public commands match, try internal commands |
src/vcpkg/commands.env.cpp
Outdated
{ | ||
"vcpkg env --triplet x64-windows", | ||
msgCommandEnvExample2, | ||
"vcpkg env \"ninja -C build\" --triplet x64-windows", |
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.
"vcpkg env \"ninja -C build\" --triplet x64-windows", | |
"vcpkg env \"ninja --version\" --triplet x64-windows", |
A relative path argument to ninja is a bit fraught here since env doesn't retain the outer CWD.
src/vcpkg/commands.help.cpp
Outdated
auto msg = msg::format(msgAvailableHelpTopics); | ||
for (auto&& topic_name : all_topic_names) | ||
{ | ||
msg.append_raw(fmt::format("\n {}", topic_name)); |
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.
Should this use LocalizedString::append_indent()
?
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.
msg.append_raw(fmt::format("\n {}", topic_name)); | |
msg.append_raw("\n").append_indent().append_raw(topic_name); |
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.
- Yes, I'll change it.
- GitHub diff fail, I didn't meaningfully change this line from line 177 in the old code.
src/vcpkg/vcpkgcmdarguments.cpp
Outdated
@@ -86,7 +86,7 @@ namespace | |||
|
|||
if (switch_.helpmsg) | |||
{ | |||
if (cmd_parser.parse_switch(name, tag, parse_result, switch_.helpmsg()) && parse_result) | |||
if (cmd_parser.parse_switch(name, tag, parse_result, switch_.helpmsg.format()) && parse_result) |
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.
(Sorry for not doing the investigation myself)
How does this avoid crashing for switches that have default constructed help (e.g. remove's OPTION_PURGE
)?
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.
The if
on line 87 will be false because operator bool
on that thing returns false if there's nothing inside
src/vcpkg/vcpkgcmdarguments.cpp
Outdated
} | ||
} | ||
|
||
void MetadataMessage::append_to(LocalizedString& target) const |
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.
void MetadataMessage::append_to(LocalizedString& target) const | |
void MetadataMessage::format_to(LocalizedString& target) const |
(suggestion)
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.
I think format_to
carries the connotation that the target's contents will be destroyed. How about format_append_to
?
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.
Changed to to_string
since we seem to use that convention elsewhere.
…ndent in all the right places for help. Also remove the "name" which need be localized from the help versioning example now that this is no longer required to avoid needing to localize it.
* drop "Commands:" from @ras0219-msft * don't repeat `vcpkg ` in front of each command from @ras0219-msft * Add 'breadcrumb' for the above * change all synopsis to not end in periods from @BillyONeal * split rarely used and artifacts into separate `vcpkg help commands` from @ras0219-msft * always use Pascal Case headers from @AugP * make tense for all synopsis and argument help text consistent from @ras0219-msft * burninate 'instead of' and 'writes out'
template<int N> | ||
/*implicit*/ constexpr LearnWebsiteLinkLiteral(const char (&literal)[N]) noexcept : literal(literal) | ||
{ | ||
assert(!constexpr_contains(literal, "en-us") && |
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.
Is there some sort of divide-by-zero or array-of-zero thing that can be done here to make this assert compile time?
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.
It is compile time; assert
is constexpr when the assertion passes and not constexpr when the assertion fails.
src/vcpkg-test/cmd-parser.cpp
Outdated
going and going | ||
shorty | ||
short-arg some really long help text that does not fit on the same line because we | ||
have a 100 character line limit and oh god it keeps going and going |
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.
have a 100 character line limit and oh god it keeps going and going | |
have a 100 character line limit and oh no it keeps going and going |
src/vcpkg/commands.cpp
Outdated
void print_full_command_list() | ||
{ | ||
HelpTableFormatter table; | ||
format_command_usage_entry(table, CommandAcquireMetadata); |
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.
This seems easy to miss when adding new commands.
Do we have a list of all commands somewhere else we could loop through, skipping based on undocumented, etc?
src/vcpkg/commands.cpp
Outdated
format_command_usage_entry(table, CommandFetchMetadata); | ||
format_command_usage_entry(table, CommandVersionMetadata); | ||
format_command_usage_entry(table, CommandVsInstancesMetadata); | ||
format_command_usage_entry(table, CommandIntegrateMetadata); | ||
table.blank(); | ||
|
||
table.header(msg::format(msgForMoreHelp)); | ||
table.format("vcpkg help topics", msg::format(msgHelpTopicsCommand)); |
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.
Consider dropping vcpkg
from these entries.
# Conflicts: # src/vcpkg/commands.cache.cpp # src/vcpkg/commands.cpp # src/vcpkg/commands.help.cpp
This PR fixes the remaining issues noted in #1164
vcpkg buildexternal
but it isvcpkg build-external
commands.cpp
. This is now the one file in the codebase that has to include all the other commands' headers.MessageT<>
where possible rather than needing to make a thunk for everything.Future work that would be nice I'm not signing up to do:
Before and after screenshots:
No arguments:
help install:
Autocomplete: