Skip to content
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

CLI: Improve argument parsing & console output formatting #1014

Merged
merged 6 commits into from Sep 15, 2022

Conversation

ubruhin
Copy link
Member

@ubruhin ubruhin commented Sep 14, 2022

Improve behavior of argument parser

  • Support passing options as --arg value in addition to --arg=value.
  • Improve error messages when passing too few or too many arguments.
  • When passing invalid or too few arguments, show only a short help text instead of the full --help page (to keep the focus on the error message).
  • Remove unintended option --help-all which was automatically added by Qt but is not really useful.
  • Remove unintended option -? which was automatically added by Qt, but only on Windows. Removing it to keep the options identical across all operating systems.

Print file format version in "--version" output

In some cases, not the application version but only the file format version is of interest so let's print that number.

$ librepcb-cli --version
LibrePCB CLI Version 0.2.0-unstable
File Format 0.2 (unstable)
Git Revision 31f3132e3
Qt Version 5.15.5 (compiled against 5.15.5)
Built at 11.09.22 23:29

Output any file paths with native separators

On Windows, output filepaths in stdout and stderr with backslash as directory separator. Just for consistency with other Windows applications.

Fix inconsistent quoting of filepaths in output

In stdout/stderr, consistently quote filepaths with single ticks (') to improve readability of paths which contain whitespaces.

Functional tests: Add many more CLI tests

Added tests for more commands, and now testing the exact output of stdout and stderr. Might be a bit annoying when modifying the output formatting since many tests might be affected, but I think it helps to detect issues like the inconsistent formatting/quoting, unintended Qt arguments etc.

CI: Run functional CLI tests with "-vvv"

Helps to debug failed tests on CI - especially useful since many more text comparisons are now made where we want to see the exact diff on failure.

On Windows, output filepaths in stdout and stderr with backslash as
directory separator. Just for consistency with other Windows
applications.
In stdout/stderr, consistently quote filepaths with single ticks (') to
improve readability of paths which contain whitespaces.
- Support passing options as "--arg value" in addition to "--arg=value".
- Improve error messages when passing too few or too many arguments.
- When passing invalid or too few arguments, show only a short help
  text instead of the full "--help" page (to keep the focus on the
  error message).
- Remove unintended option "--help-all" which was automatically added
  by Qt but is not really useful.
- Remove unintended option "-?" which was automatically added by Qt,
  but only on Windows. Removing it to keep the options identical
  across all operating systems.
Helps to debug failed tests on CI.
@ubruhin ubruhin added enhancement tool-cli Issues affecting librepcb-cli labels Sep 14, 2022
@ubruhin ubruhin added this to the 0.1.7 milestone Sep 14, 2022
@ubruhin ubruhin self-assigned this Sep 14, 2022
@ubruhin ubruhin changed the title CLI: Improve parser behavior & console output formatting CLI: Improve argument parsing & console output formatting Sep 14, 2022
@ubruhin ubruhin merged commit 62260b8 into master Sep 15, 2022
@ubruhin ubruhin deleted the cli-argument-parser-improvements branch September 15, 2022 09:40
ubruhin added a commit that referenced this pull request Sep 26, 2022
CLI: Improve argument parsing & console output formatting
(cherry picked from commit 62260b8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement tool-cli Issues affecting librepcb-cli
Development

Successfully merging this pull request may close these issues.

None yet

1 participant