diff --git a/programpack/__init__.py b/programpack/__init__.py index 04045ae..17c1a58 100644 --- a/programpack/__init__.py +++ b/programpack/__init__.py @@ -12,10 +12,16 @@ from warnings import warn from requests import get as r_get +__app_name__ = 'ProgramPack' __all__ = [ 'PackedProgram', 'convert_file_to_executable', 'deconvert', 'create_archive' ] __version__ = '0.0.1' +__meta__ = { + 'name': __app_name__, + 'version': __version__, + '__all__': __all__ +} shebang = b'#!/usr/bin/env -S python3 -m programpack run\n' shebang_v = b'#!/usr/bin/env -S python3 -m programpack run --virtual\n' diff --git a/programpack/__main__.py b/programpack/__main__.py index 28244ad..035692e 100644 --- a/programpack/__main__.py +++ b/programpack/__main__.py @@ -2,15 +2,24 @@ from sys import argv as args from os import system as execute from tempfile import gettempdir as get_temp_dir +from json import dumps as dump_to_json import programpack as propack -def pull_from_git(): - execute(f'''cd {get_temp_dir()}; -git clone https://github.com/ProgramPack/programpack.git -b experimental && mv programpack programpack-exp-branch; -cd programpack-exp-branch; -make sinstall && make sclean; +def pull_from_git(branch): + cmd = f'cd {get_temp_dir()};\n' + if branch: + branch = branch.strip() + cmd += f'git clone https://github.com/ProgramPack/programpack.git -b "{branch}" && mv programpack programpack-custom-branch;\n' + cmd += 'cd programpack-custom-branch;\n' + else: + cmd += f'git clone https://github.com/ProgramPack/programpack.git -b experimental && mv programpack programpack-exp-branch;\n' + cmd += 'cd programpack-exp-branch;\n' + cmd += '''make sinstall && make sclean; cd ..; -true && rm -rf programpack-exp-branch;''') +true && ''' + if branch: cmd += 'rm -rf programpack-custom-branch;' + else: cmd += 'rm -rf programpack-exp-branch;' + execute(cmd) try: argv1 = args[1] except IndexError: argv1 = None @@ -47,12 +56,18 @@ def pull_from_git(): Will attempt to remove the shebang(s) from given file create Create archive from directory name - pull + pull [branch] Update `ProgramPack` to latest version + If `branch` is used, it will pull from branch. + info + See all information about current `ProgramPack` version in JSON version See current version manifest Print manifest of file + icon + icon update + Will update file icon manually. hub hub download [output] Will download ProgramPack file by name, domain and author from hub.''' @@ -80,11 +95,23 @@ def pull_from_git(): propack.create_archive(argv2, argv3 or 'create') else: print('usage: create ') -elif argv1 == 'pull': pull_from_git() +elif argv1 == 'pull': pull_from_git(branch = argv2) +elif argv1 == 'info': print(str(dump_to_json(propack.__meta__))) elif argv1 == 'version': print('ProgramPack - Version {}'.format(propack.__version__)) elif argv1 == 'manifest': if argv2: - print(propack.get_manifest(argv2), end = '') + try: print(propack.get_manifest(argv2), end = '') + except FileNotFoundError: print('error: file {argv2} doesn\'t exist') + else: print('usage: manifest ') +elif argv1 == 'icon': + if argv2: + try: + program = propack.PackedProgram(argv2) + program.update_icon(verbose = verbose) + except FileNotFoundError: + print(f'error: file {argv2} doesn\'t exist') + else: + print('usage: icon ') elif argv1 == 'hub': if argv2: if argv2 == 'download': @@ -94,7 +121,7 @@ def pull_from_git(): print('usage: hub download [output]') else: print('Unknown hub command. See --help') else: - print('usage: hub <>') + print('usage: hub <...>') else: if len(args) <= 1: print('No args given. See --help.') else: print('Invalid arguments. See --help for more info.')