Skip to content

Commit

Permalink
add torchfix --version (#14)
Browse files Browse the repository at this point in the history
* add torchfix --version

Also changes the default command to not require an argument and to
default to your current working directory

Signed-off-by: Eli Uriegas <[email protected]>

* get rid of default for path, print usage if left blank

Signed-off-by: Eli Uriegas <[email protected]>

---------

Signed-off-by: Eli Uriegas <[email protected]>
  • Loading branch information
seemethere authored Jan 27, 2024
1 parent 9e2c8e6 commit a776f3e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions torchfix/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import io

from .torchfix import TorchCodemod, TorchCodemodConfig
from .torchfix import TorchCodemod, TorchCodemodConfig, __version__ as TorchFixVersion
from .common import CYAN, ENDC


Expand All @@ -14,7 +14,7 @@ def main() -> None:

parser.add_argument(
"path",
nargs="+",
nargs="*",
help=("Path to check/fix. Can be a directory, a file, or multiple of either."),
)
parser.add_argument(
Expand All @@ -36,6 +36,11 @@ def main() -> None:
"ALL",
],
)
parser.add_argument(
"--version",
action="store_true",
help="Print current version.",
)

# XXX TODO: Get rid of this!
# Silence "Failed to determine module name"
Expand All @@ -47,6 +52,15 @@ def main() -> None:

args = parser.parse_args()

if args.version:
# TODO: Perhaps add commit hash here if we can
print(f"{TorchFixVersion}")
sys.exit(0)

if not args.path:
parser.print_usage()
sys.exit(1)

files = codemod.gather_files(args.path)

# Filter out files that don't have "torch" string in them.
Expand Down

0 comments on commit a776f3e

Please sign in to comment.