Skip to content

Commit 2d34814

Browse files
committed
Move position of main function
1 parent 502bc3a commit 2d34814

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/fosslight_util/download.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,37 +92,6 @@ def parse_src_link(src_link):
9292
return src_info
9393

9494

95-
def main():
96-
parser = argparse.ArgumentParser(description='FOSSLight Downloader', prog='fosslight_download', add_help=False)
97-
parser.add_argument('-h', '--help', help='Print help message', action='store_true', dest='help')
98-
parser.add_argument('-s', '--source', help='Source link to download', type=str, dest='source')
99-
parser.add_argument('-t', '--target_dir', help='Target directory', type=str, dest='target_dir', default="")
100-
parser.add_argument('-d', '--log_dir', help='Directory to save log file', type=str, dest='log_dir', default="")
101-
102-
src_link = ""
103-
target_dir = os.getcwd()
104-
log_dir = os.getcwd()
105-
106-
try:
107-
args = parser.parse_args()
108-
except SystemExit:
109-
sys.exit(0)
110-
111-
if args.help:
112-
print_help_msg_download()
113-
if args.source:
114-
src_link = args.source
115-
if args.target_dir:
116-
target_dir = args.target_dir
117-
if args.log_dir:
118-
log_dir = args.log_dir
119-
120-
if not src_link:
121-
print_help_msg_download()
122-
else:
123-
cli_download_and_extract(src_link, target_dir, log_dir)
124-
125-
12695
def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_to: str = "",
12796
compressed_only: bool = False, ssh_key: str = "") -> Tuple[bool, str, str, str]:
12897
global logger
@@ -466,5 +435,36 @@ def gem_download(link, target_dir, checkout_to):
466435
return success
467436

468437

438+
def main():
439+
parser = argparse.ArgumentParser(description='FOSSLight Downloader', prog='fosslight_download', add_help=False)
440+
parser.add_argument('-h', '--help', help='Print help message', action='store_true', dest='help')
441+
parser.add_argument('-s', '--source', help='Source link to download', type=str, dest='source')
442+
parser.add_argument('-t', '--target_dir', help='Target directory', type=str, dest='target_dir', default="")
443+
parser.add_argument('-d', '--log_dir', help='Directory to save log file', type=str, dest='log_dir', default="")
444+
445+
src_link = ""
446+
target_dir = os.getcwd()
447+
log_dir = os.getcwd()
448+
449+
try:
450+
args = parser.parse_args()
451+
except SystemExit:
452+
sys.exit(0)
453+
454+
if args.help:
455+
print_help_msg_download()
456+
if args.source:
457+
src_link = args.source
458+
if args.target_dir:
459+
target_dir = args.target_dir
460+
if args.log_dir:
461+
log_dir = args.log_dir
462+
463+
if not src_link:
464+
print_help_msg_download()
465+
else:
466+
cli_download_and_extract(src_link, target_dir, log_dir)
467+
468+
469469
if __name__ == '__main__':
470470
main()

0 commit comments

Comments
 (0)