Skip to content

Commit

Permalink
fix(scripts): Fixed python script usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
na2axl committed Apr 8, 2024
1 parent 8bfa751 commit f8db952
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
1 change: 0 additions & 1 deletion scripts/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"""

import common
import os
import sys


Expand Down
9 changes: 5 additions & 4 deletions scripts/clean_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"""

import common
import os
import sys


Expand All @@ -31,11 +30,13 @@ def main(argv):
Returns 0 on success.
"""

project_path = common.get_amplitude_project_path()
options = common.CommandOptions(argv, "clean_project", "0.2.0")

try:
common.clean_flatbuffers_binaries(
common.get_conversion_data(os.path.join(project_path, "sources"))
common.get_conversion_data(options.project_path),
options.project_path,
options.build_path
)
print("Amplitude binary assets cleaned successfully.")
except common.BuildError as error:
Expand All @@ -46,4 +47,4 @@ def main(argv):


if __name__ == '__main__':
main(sys.argv)
main(sys.argv[1:])
25 changes: 19 additions & 6 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,36 @@ class CommandOptions(object):

def __init__(self, argv, script_name: str, script_version: str):
opts, args = getopt.getopt(argv, "hvp:b:f:",
["help", "version", "project-path", "build-path", "flatc"])
["help", "version", "project-path", "build-path", "flatc", "no-logo"])

no_logo = False
show_help = False
show_version = False

for opt, arg in opts:
if opt in ("-h", "--help"):
print_help(False, script_name)
sys.exit(0)
if opt is "--no-logo":
no_logo = True
elif opt in ("-h", "--help"):
show_help = True
elif opt in ("-v", "--version"):
print("{}.py {}".format(script_name, script_version))
show_version = True
elif opt in ("-p", "--project-path"):
self.project_path = arg
elif opt in ("-b", "--build-path"):
self.build_path = arg
elif opt in ("-f", "--flatc"):
self.flatc_path = arg

if show_help:
print_help(no_logo, script_name)
sys.exit(0)

if show_version:
print("{}.py {}".format(script_name, script_version))
sys.exit(0)

if self.project_path == '' or self.build_path == '':
print_help(False, script_name)
print_help(no_logo, script_name)
sys.exit(1)


Expand Down

0 comments on commit f8db952

Please sign in to comment.