|
@@ -8,7 +8,7 @@ from pathlib import Path
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
-from tidy import create
|
|
|
+from . import create
|
|
|
|
|
|
|
|
|
def examineFile(file, settings):
|
|
@@ -72,7 +72,24 @@ def formatFile(file: Path, settings):
|
|
|
config.write(f, space_around_delimiters=settings["format"].get("format-profile-space-around-delimiters", True))
|
|
|
|
|
|
|
|
|
-def main(files, setting_path, to_format, to_fix, to_diagnose, report):
|
|
|
+def main():
|
|
|
+ parser = ArgumentParser(
|
|
|
+ description="UltiMaker Cura printer linting, static analysis and formatting of Cura printer definitions and other resources")
|
|
|
+ parser.add_argument("--setting", required=False, type=Path, help="Path to the `.printer-linter` setting file")
|
|
|
+ parser.add_argument("--report", required=False, type=Path, help="Path where the diagnostic report should be stored")
|
|
|
+ parser.add_argument("--format", action="store_true", help="Format the files")
|
|
|
+ parser.add_argument("--diagnose", action="store_true", help="Diagnose the files")
|
|
|
+ parser.add_argument("--fix", action="store_true", help="Attempt to apply the suggested fixes on the files")
|
|
|
+ parser.add_argument("Files", metavar="F", type=Path, nargs="+", help="Files or directories to format")
|
|
|
+
|
|
|
+ args = parser.parse_args()
|
|
|
+ files = args.Files
|
|
|
+ setting_path = args.setting
|
|
|
+ to_format = args.format
|
|
|
+ to_fix = args.fix
|
|
|
+ to_diagnose = args.diagnose
|
|
|
+ report = args.report
|
|
|
+
|
|
|
if not setting_path:
|
|
|
setting_path = Path(getcwd(), ".printer-linter")
|
|
|
|
|
@@ -118,14 +135,4 @@ def main(files, setting_path, to_format, to_fix, to_diagnose, report):
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
- parser = ArgumentParser(
|
|
|
- description="UltiMaker Cura printer linting, static analysis and formatting of Cura printer definitions and other resources")
|
|
|
- parser.add_argument("--setting", required=False, type=Path, help="Path to the `.printer-linter` setting file")
|
|
|
- parser.add_argument("--report", required=False, type=Path, help="Path where the diagnostic report should be stored")
|
|
|
- parser.add_argument("--format", action="store_true", help="Format the files")
|
|
|
- parser.add_argument("--diagnose", action="store_true", help="Diagnose the files")
|
|
|
- parser.add_argument("--fix", action="store_true", help="Attempt to apply the suggested fixes on the files")
|
|
|
- parser.add_argument("Files", metavar="F", type=Path, nargs="+", help="Files or directories to format")
|
|
|
-
|
|
|
- args = parser.parse_args()
|
|
|
- main(args.Files, args.setting, args.format, args.fix, args.diagnose, args.report)
|
|
|
+ main()
|