Skip to content

Commit

Permalink
fix. Renamed --listfixes to --listfixers. Closes #76.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamere-allo-peter committed Mar 22, 2022
1 parent d159011 commit 94c972e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions yamlfixer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def run():
cmdline.add_argument("-d", "--debug",
action="store_true",
help="output debug information to stderr.")
cmdline.add_argument("-l", "--listfixes",
cmdline.add_argument("-l", "--listfixers",
action="store_true",
help="output the list of available fixes.")
help="output the list of available fixers.")
mutuallyexclusive = cmdline.add_mutually_exclusive_group()
mutuallyexclusive.add_argument("-j", "--jsonsummary",
action="store_true",
Expand All @@ -90,9 +90,10 @@ def run():
if cmdline.prog == "__main__.py":
cmdline.prog = "yamlfixer"
arguments = cmdline.parse_args()
if arguments.listfixes:
return YAMLFixer(arguments).listfixes()
return YAMLFixer(arguments).fix()
yfixer = YAMLFixer(arguments)
if arguments.listfixers:
return yfixer.listfixers()
return yfixer.fix()

if __name__ == '__main__':
sys.exit(run())
12 changes: 6 additions & 6 deletions yamlfixer/yamlfixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ def statistics(self):
}
self.info(json.dumps(summarymapping, indent=4))

def listfixes(self):
"""List all the available fixes."""
availablefixes = []
def listfixers(self):
"""List all the available fixers."""
availablefixers = []
for methodname in [m for m in dir(ProblemFixer) if m.startswith('fix_')]:
docstring = getattr(ProblemFixer, methodname).__doc__
for prob in [pb.strip()[2:] for pb in docstring.splitlines()[1:]]:
if prob:
availablefixes.append(prob)
self.info("fixes:")
for fixstr in sorted(availablefixes):
availablefixers.append(prob)
self.info("fixers:")
for fixstr in sorted(availablefixers):
self.info(f" - {fixstr}")
return EXIT_OK

Expand Down

0 comments on commit 94c972e

Please sign in to comment.