Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install packages programmatically? #1597

Closed
dbeckwith opened this issue Sep 22, 2021 · 4 comments
Closed

Install packages programmatically? #1597

dbeckwith opened this issue Sep 22, 2021 · 4 comments

Comments

@dbeckwith
Copy link

Is there any official way to install packages without having to use the sublime UI? I'd like to be able to write an external script that will install/uninstall packages by name. I had a look through the source code and couldn't find any registered sublime commands that directly install a package. There's InstallPackageCommand but it just opens a separate window which eventually calls PackageManager, and the actual install code is located there. Is there a way to expose some of the functionality of PackageManager directly as sublime commands? If there isn't but you think this is a useful thing to have, I might be willing to contribute a patch. Thanks for the great package!

@dbeckwith
Copy link
Author

Hmm so I found #883 which has some tips on running the provided commands. I'm able to install packages with something like window.run_command('advanced_install_package', {'packages':['my package']}), but there's no equivalent I can find for removing packages.

@dbeckwith
Copy link
Author

Something like #1361 would also be useful for my purposes.

@deathaxe deathaxe added this to the Package Control 4.0 milestone Feb 5, 2023
@deathaxe
Copy link
Collaborator

deathaxe commented Feb 5, 2023

Source code to handle installations is bundled with ST's API and thus can't be run in a dedicated shell.

All relevant commands to handle installation, upgrade, removal, enabling or disabling packages will be available in PC 4.0 and can be executed using subl.

Install Packages

subl -b --command 'install_packages {"packages": ["package1", "package2"]}'

Upgrade Packages

subl -b --command 'upgrade_packages {"packages": ["package1", "package2"]}'

Upgrade All Packages

subl -b --command 'upgrade_all_packages'

Remove Packages

subl -b --command 'remove_packages {"packages": ["package1", "package2"]}'

Enable Packages

subl -b --command 'enable_packages {"packages": ["package1", "package2"]}'

Disable Packages

subl -b --command 'disable_packages {"packages": ["package1", "package2"]}'

@dbeckwith
Copy link
Author

That sounds perfect, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants