Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Add a -C like make and git to tell where to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPalard committed Oct 25, 2021
1 parent 3dcd6c7 commit dc9f814
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion powrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Julien Palard"""
__email__ = "[email protected]"
__version__ = "0.4.0"
__version__ = "1.0.0"
23 changes: 20 additions & 3 deletions powrap/powrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import sys
import os
from typing import Iterable
import difflib
from pathlib import Path
Expand Down Expand Up @@ -96,7 +97,18 @@ def path(path_str):
127:error running msgcat""",
)
parser.add_argument(
"--modified", "-m", action="store_true", help="Use git to find modified files."
"--modified",
"-m",
action="store_true",
help="Use git to find modified files instead of passing them as arguments.",
)
parser.add_argument(
"-C",
help="To use with --modified to tell where the git "
"repo is, in case it's not in the current working directory.",
type=Path,
dest="git_root",
default=Path.cwd(),
)
parser.add_argument(
"--quiet", "-q", action="store_true", help="Do not show progress bar."
Expand All @@ -115,7 +127,6 @@ def path(path_str):
"Return code 0 means nothing would change. "
"Return code 1 means some files would be reformatted.",
)

parser.add_argument(
"--version", action="version", version="%(prog)s " + __version__
)
Expand All @@ -129,15 +140,21 @@ def path(path_str):
if not args.po_files and not args.modified:
parser.print_help()
sys.exit(1)
if args.po_files and args.modified:
parser.print_help()
sys.exit(1)
return args


def main():
"""Powrap main entrypoint (parsing command line and all)."""
args = parse_args()
if args.git_root:
os.chdir(args.git_root)
if args.modified:
git_status = check_output(
["git", "status", "--porcelain", "--no-renames"], encoding="utf-8"
["git", "status", "--porcelain", "--no-renames"],
encoding="utf-8",
)
git_status_lines = [
line.split(maxsplit=2) for line in git_status.split("\n") if line
Expand Down
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ classifiers =
License :: OSI Approved :: MIT License
Natural Language :: English
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9

[options]
packages = powrap
Expand Down

0 comments on commit dc9f814

Please sign in to comment.