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

Refactor cli / arg parsing #4563

Merged
merged 4 commits into from
Feb 29, 2024
Merged

Refactor cli / arg parsing #4563

merged 4 commits into from
Feb 29, 2024

Conversation

simoncozens
Copy link
Collaborator

@simoncozens simoncozens commented Feb 29, 2024

Description

Relates to issue #4562

This PR merges the cli.py and commands/check_profile.py modules, simplifying them both and removing the warning message reported in the issue. It also organises the command line arguments into groups for good measure. I looked into fixing #4183 (comment) - I managed it, but realised it would be backwards incompatible, so maybe not for now.

fontbakery check-googlefonts --help

usage: __main__.py check-googlefonts [-h] [-L] [--configuration CONFIGFILE]
                                     [-c CHECKID] [-x EXCLUDE_CHECKID] [-v]
                                     [-l LOGLEVEL] [-m LOGLEVEL_MESSAGES]
                                     [--succinct] [-F] [-S] [-g ITERATED_ARG]
                                     [-o ORDER] [-q] [-n] [-C]
                                     [--dark-theme | --light-theme]
                                     [--timeout TIMEOUT | --skip-network]
                                     [--json JSON_FILE] [--badges DIRECTORY]
                                     [--ghmarkdown MD_FILE] [--html HTML_FILE]
                                     [-J JOBS] [-j] [-e ERROR_CODE_ON]
                                     [files ...]

positional arguments:
  files                 file path(s) to check. Wildcards like *.ttf are
                        allowed.

options:
  -h, --help            show this help message and exit
  -L, --list-checks     List the checks available in the selected profile.
  --configuration CONFIGFILE
                        Read configuration file (TOML/YAML).
  -c CHECKID, --checkid CHECKID
                        Explicit check-ids (or parts of their name) to be
                        executed. Use this option multiple times to select
                        multiple checks.
  -x EXCLUDE_CHECKID, --exclude-checkid EXCLUDE_CHECKID
                        Exclude check-ids (or parts of their name) from
                        execution. Use this option multiple times to exclude
                        multiple checks.
  -J JOBS, --jobs JOBS  Use multi-processing to run the checks. The argument
                        is the number of worker processes. A sensible number
                        is the cpu count of your system, detected: 8. As an
                        automated shortcut see -j/--auto-jobs. Use 1 to run in
                        single-processing mode (default 1).
  -j, --auto-jobs       Use the auto detected cpu count (= 8) as number of
                        worker processes in multi-processing. This is
                        equivalent to : `--jobs 8`
  -e ERROR_CODE_ON, --error-code-on ERROR_CODE_ON
                        Threshold for emitting process error code 1. (Useful
                        for deciding the criteria for breaking a continuous
                        integration job) One of: DEBUG, PASS, SKIP, INFO,
                        WARN, FAIL, FATAL, ERROR. (default: FAIL)

Logging:
  Options which control the amount and order of output

  -v, --verbose         Shortcut for '-l PASS'.
  -l LOGLEVEL, --loglevel LOGLEVEL
                        Report checks with a result of this status or higher.
                        One of: DEBUG, PASS, SKIP, INFO, WARN, FAIL, FATAL,
                        ERROR. (default: WARN)
  -m LOGLEVEL_MESSAGES, --loglevel-messages LOGLEVEL_MESSAGES
                        Report log messages of this status or higher. Messages
                        are all status lines within a check. One of: DEBUG,
                        PASS, SKIP, INFO, WARN, FAIL, FATAL, ERROR. (default:
                        LOGLEVEL)
  --succinct            This is a slightly more compact and succint output
                        layout.
  -F, --full-lists      Do not shorten lists of items.
  -S, --show-sections   Show section summaries.
  -g ITERATED_ARG, --gather-by ITERATED_ARG
                        Optional: collect results by ITERATED_ARG In terminal
                        output: create a summary counter for each
                        ITERATED_ARG. In json output: structure the document
                        by ITERATED_ARG. One of: designspace, font,
                        glyphs_file, metadata_pb, readme_md, ufo, *check
  -o ORDER, --order ORDER
                        Comma separated list of order arguments. The execution
                        order is determined by the order of the check
                        definitions and by the order of the iterable
                        arguments. A section defines its own order. `--order`
                        can be used to override the order of *all* sections.
                        Despite the ITERATED_ARGS there are two special values
                        available: "*iterargs" -- all remainig ITERATED_ARGS
                        "*check" -- order by check ITERATED_ARGS: designspace,
                        font, glyphs_file, metadata_pb, readme_md, ufo A
                        sections default is equivalent to: "*iterargs,
                        *check". A common use case is `-o "*check"` when
                        checking the whole collection against a selection of
                        checks picked with `--checkid`.

Terminal:
  Options related to terminal output

  -q, --quiet           Be quiet, don’t report anything on the terminal.
  -n, --no-progress     Suppress the progress indicators in the console
                        output.
  -C, --no-colors       Suppress the coloring theme in the console output.
  --dark-theme          Use a color theme with dark colors.
  --light-theme         Use a color theme with light colors.

Network:
  Network related options

  --timeout TIMEOUT     Timeout (in seconds) for network operations.
  --skip-network        Skip network checks

Reports:
  Options which control report generation

  --json JSON_FILE      Write a json formatted report to JSON_FILE.
  --badges DIRECTORY    Write a set of shields.io badge files to DIRECTORY.
  --ghmarkdown MD_FILE  Write a GitHub-Markdown formatted report to MD_FILE.
  --html HTML_FILE      Write a HTML report to HTML_FILE.

Checklist

  • update CHANGELOG.md
  • wait for the tests to pass
  • request a review

@bobh0303
Copy link
Contributor

Thanks! check-profile even works now :-)

@felipesanches felipesanches merged commit dd3fe5d into main Feb 29, 2024
40 checks passed
@khaledhosny khaledhosny deleted the refactor-cli branch February 29, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants