forked from beeware/voc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Did a proper job on the __main__ entrypoint.
This adds a verbosity flag, plus proper flags for output directory and prefixing.
- Loading branch information
1 parent
c1bd25e
commit 592a87f
Showing
12 changed files
with
128 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,49 @@ | ||
import sys | ||
from .transpiler import transpile | ||
import argparse | ||
|
||
|
||
def main(): | ||
if len(sys.argv) == 2: | ||
srcdir = '.' | ||
outdir = None | ||
elif len(sys.argv) == 3: | ||
srcdir = sys.argv[2] | ||
outdir = None | ||
elif len(sys.argv) == 4: | ||
srcdir = sys.argv[2] | ||
outdir = sys.argv[3] | ||
else: | ||
print("Usage: voc <path to .py file> [<input prefix>] [<output dir>]") | ||
print() | ||
print(' e.g.: voc tests/example.py src out') | ||
sys.exit(1) | ||
parser = argparse.ArgumentParser( | ||
prog='voc', | ||
description='Transpiles Python code to Java class files.' | ||
) | ||
|
||
transpile(sys.argv[1], srcdir=srcdir, outdir=outdir) | ||
parser.add_argument( | ||
'-o', '--output', | ||
help='The directory where class files should be output.', | ||
default='.' | ||
) | ||
parser.add_argument( | ||
'-p', '--prefix', | ||
help='The prefix to strip from all source file paths.', | ||
default='.' | ||
) | ||
parser.add_argument( | ||
'-n', '--namespace', | ||
help='The namespace for the generated Java classfiles.', | ||
default='python' | ||
) | ||
parser.add_argument( | ||
'-v', '--verbosity', | ||
action='count', | ||
default=0 | ||
) | ||
parser.add_argument( | ||
'input', | ||
metavar='source file', | ||
nargs='+', | ||
help='The source file or directory to compile' | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
if __name__ == "__main__": | ||
transpile( | ||
input=args.input, | ||
prefix=args.prefix, | ||
outdir=args.output, | ||
namespace=args.namespace, | ||
verbosity=args.verbosity | ||
) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.