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

Automate generate options #578

Merged
merged 1 commit into from
Aug 8, 2021
Merged

Automate generate options #578

merged 1 commit into from
Aug 8, 2021

Conversation

tefra
Copy link
Owner

@tefra tefra commented Aug 8, 2021

Description

Almost all the generator flag options are available only through config. I want to be able to toggle and override any flag or directive from the config.

What I did

  • I added a new decorator that accepts a dataclass and builds click.options dynamically
  • The new options support enabling/disabling any flag and overriding the options in the config as well
  • Deprecated short names -cf/-ri since the click true/false arguments can't have secondary names

8 new options are now available as cli options 🆗

  -c, --config TEXT               Project configuration
  -pp, --print                    Print output
  -p, --package TEXT              Target package, default: generated
  -o, --output [dataclasses]      Output format name, default: dataclasses
  --repr / --no-repr              Generate __repr__ method, default: true
  --eq / --no-eq                  Generate __eq__ method, default: true
  --order / --no-order            Generate __lt__, __le__, __gt__, and __ge__
                                  methods, default: false
  --unsafe-hash / --no-unsafe-hash
                                  Generate __hash__ method if not frozen,
                                  default: false
  --frozen / --no-frozen          Enable read only properties, default false
  --slots / --no-slots            Enable __slots__, default: false,
                                  python>=3.10 Only
  --kw-only / --no-kw-only        Enable keyword only arguments, default:
                                  false, python>=3.10 Only
  -ss, --structure-style [filenames|namespaces|clusters|single-package|namespace-clusters]
                                  Output structure style, default: filenames
  -ds, --docstring-style [reStructuredText|NumPy|Google|Accessible|Blank]
                                  Docstring style, default: reStructuredText
  --relative-imports / --no-relative-imports
                                  Use relative imports, default: false
  --compound-fields / --no-compound-fields
                                  Use compound fields for repeatable elements,
                                  default: false
  -mll, --max-line-length INTEGER
                                  Adjust the maximum line length, default: 79
  --help                          Show this message and exit.

@codecov
Copy link

codecov bot commented Aug 8, 2021

Codecov Report

Merging #578 (4a5111d) into master (d3cbb81) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 4a5111d differs from pull request most recent head 7dc04b0. Consider uploading reports for the commit 7dc04b0 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##            master      #578   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           93        95    +2     
  Lines         8059      8120   +61     
  Branches      1392      1401    +9     
=========================================
+ Hits          8059      8120   +61     
Impacted Files Coverage Δ
xsdata/codegen/handlers/class_name_conflict.py 100.00% <ø> (ø)
xsdata/cli.py 100.00% <100.00%> (ø)
xsdata/codegen/handlers/class_designate.py 100.00% <100.00%> (ø)
xsdata/models/config.py 100.00% <100.00%> (ø)
xsdata/utils/click.py 100.00% <100.00%> (ø)
xsdata/utils/objects.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3cbb81...7dc04b0. Read the comment docs.

- Generate the click options by the config model
- Allow to enable/disable any flag
- Removed -cf/-ri we can't have switches with short names
- Allow to bypass any value from the config
@tefra tefra merged commit 8242e07 into master Aug 8, 2021
@tefra tefra deleted the cli-auto branch August 8, 2021 20:23
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 8, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

1 participant