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

Add or document installing from console feature #883

Closed
NameFILIP opened this issue Feb 17, 2015 · 6 comments
Closed

Add or document installing from console feature #883

NameFILIP opened this issue Feb 17, 2015 · 6 comments

Comments

@NameFILIP
Copy link

I want to create a script that installs a set of most popular packages for a Front end developer (Emmet, LESS, Sass, SideBarEnhancements, EditorConfig, etc).

In order to accomplish this, it would be nice to have an ability not only to Install Package by hands, but also from console or command line. Something like PC.install_package("package_name/url")

P.S. I guess such functionality more or less already exists, but not well documented.

@FichteFoll
Copy link
Collaborator

You are correct, such functionality exists in form of the advanced_install_package command.

It's not documented on https://packagecontrol.io/docs/usage though.

Edit: I just noticed that the docstring of AdvancedInstallPackageCommand.on_done is totally inaccurate and a copy-paste error.

If you need to add the repository first, I suppose there is something that PC could be improved upon. Either by accepting arguments in the add_repository command or by allowing urls to be specified in the advanced_install_package command. The former sounds clearer to me use-case-wise and easier to implement.

@NameFILIP
Copy link
Author

Sorry, unfortunately, my Python skills are not as good as Java or JavaScript. How do I use the AdvancedInstallPackageCommand?

I've tried running AdvancedInstallPackageCommand.run(..) in the Sublime's Console, but it returns NameError: name 'AdvancedInstallPackageCommand' is not defined

@wbond
Copy link
Owner

wbond commented Feb 18, 2015

It isn't that I don't want to tell you the exact answer, but instead I encourage you to look at the ST docs here so you can learn more about Sublime Text. This will be useful if you are intending to build something on top of Package Control. https://www.sublimetext.com/docs/3/api_reference.html

@NameFILIP
Copy link
Author

I've spend about an hour trying to figure out how to make it work. I would appreciate some guidance.

As I said, I am far from Python expert. The code that almost works:

import package_control.commands.advanced_install_package_command
package_control.commands.advanced_install_package_command.AdvancedInstallPackageCommand.run("Emmet, SideBarEnhancements")

The problem is that here the first parameter is self. I've tried to pass package_control.commands.advanced_install_package_command.AdvancedInstallPackageCommand there, but unsuccessfully. So what should I pass there?

@FichteFoll
Copy link
Collaborator

I'll give you a few tips. Hopefully not too much, but it seems you are really missing the fundamentals.

First, the self parameter is the reference to the object instance in particular since this is a "bound" method. Pretty much like this in C++ and Java but more flexible. So, technically you would need to create a new instance first by calling the constructor (inherited from sublime_plugin.WindowCommand) and then call the run method of that object. However, this is not how commands work in Sublime Text.

So the second tip is: There are API functions to "run" commands. Commands are the main interface between anything that registers events and anything that does something in ST (key bindings, menu items, the command palette all use the "command interface"). Maybe this is worth a read.

And the final tip, command names of Python classes (that subclass a sublime_plugin.*Command class) are automatically converted to snake_case and the trailing Command is stripped, so the above command name would be converted to advanced_install_package, as indicated by my link text.

@deathaxe
Copy link
Collaborator

deathaxe commented Dec 5, 2023

All major commands are available from command line in Package Control.

see: #1597 (comment)

@deathaxe deathaxe closed this as completed Dec 5, 2023
@deathaxe deathaxe added this to the Package Control 4.0 milestone Dec 5, 2023
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

4 participants