add --press-to-continue flag to edenfsctl commands

Summary:
When an `edenfsctl` command is invoked from the E-Menu, a PowerShell Window is opened and is immediately closed once the command finishes. This makes it hard/impossible for the user to see the command's output.

The desired behavior here is to keep the Window open long enough for the user to acknowledge the output. I did this by adding a `--press-to-continue` flag to all `edenfsctl` commands. This will mainly be used by the E-Menu, but may have uses elsewhere.

Reviewed By: chadaustin

Differential Revision: D36137709

fbshipit-source-id: a46bebb5bb5820949cd4b70579a29406afb34048
This commit is contained in:
Michael Cuevas 2022-05-04 21:20:06 -07:00 committed by Facebook GitHub Bot
parent 64548ed91b
commit 23fd6f25d0
2 changed files with 27 additions and 13 deletions

View File

@ -2172,6 +2172,11 @@ def create_parser() -> argparse.ArgumentParser:
action="store_true",
help="Enable debug mode (more verbose logging, traceback, etc..)",
)
parser.add_argument(
"--press-to-continue",
action="store_true",
help=argparse.SUPPRESS,
)
subcmd_add_list: List[Type[Subcmd]] = [
subcmd_mod.HelpCmd,
@ -2307,7 +2312,10 @@ def main() -> int:
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
try:
return asyncio_run(async_main(parser, args))
ret = asyncio_run(async_main(parser, args))
if args.press_to_continue:
input("\n\nPress enter to continue...")
return ret
except KeyboardInterrupt:
# If a Thrift stream is interrupted, Folly EventBus/NotificationQueue
# gets into a wonky state, and attempting to garbage collect the

View File

@ -248,6 +248,22 @@ void showWinNotification(HWND hwnd, const WindowsNotification& notif) {
"Failed to show E-Menu notification");
}
void executeShellCommand(std::string_view cmd, std::string_view params) {
SHELLEXECUTEINFOW pExecInfo = {};
pExecInfo.cbSize = sizeof(pExecInfo);
// TODO(@cuev): Allow users to specify what shell they want us to
// launch the report command with
pExecInfo.fMask = SEE_MASK_NOASYNC;
pExecInfo.lpVerb = L"open";
auto cmdStr = multibyteToWideString(cmd);
auto paramsStr = multibyteToWideString(params);
pExecInfo.lpFile = cmdStr.c_str();
pExecInfo.lpParameters = paramsStr.c_str();
pExecInfo.nShow = SW_SHOWNORMAL;
auto errStr = fmt::format("Failed to excute command: {} {}", cmd, params);
checkNonZero(ShellExecuteExW(&pExecInfo), errStr);
}
LRESULT CALLBACK
WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) noexcept {
try {
@ -328,18 +344,8 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) noexcept {
}
case IDM_EDENREPORT: {
SHELLEXECUTEINFOW pExecInfo = {};
pExecInfo.cbSize = sizeof(pExecInfo);
// TODO(@cuev): Allow users to specify what shell they want us to
// launch the report command with
pExecInfo.fMask = SEE_MASK_NOASYNC;
pExecInfo.lpVerb = L"open";
pExecInfo.lpFile = L"edenfsctl";
pExecInfo.lpParameters = L"rage --report";
pExecInfo.nShow = SW_SHOWNORMAL;
checkNonZero(
ShellExecuteExW(&pExecInfo),
"Failed to launch EdenFS report script");
executeShellCommand(
"edenfsctl", "--press-to-continue rage --report");
return 0;
}