/
enable_package_command.py
56 lines (39 loc) · 1.47 KB
/
enable_package_command.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sublime
from ..package_disabler import PackageDisabler
from .existing_packages_command import ExistingPackagesCommand
class EnablePackageCommand(ExistingPackagesCommand):
"""
A command that removes a package from Sublime Text's ignored packages list
"""
def action(self):
"""
Build a strng to describe the action taken on selected package.
"""
return "enable"
def no_packages_error(self):
"""
Return the error message to display if no packages are availablw.
"""
return "There are no disabled packages to enable"
def list_packages(self, manager):
"""
Build a list of packages to display.
:param manager:
The package manager instance to use.
:returns:
A list of package names to add to the quick panel
"""
return sorted(
filter(lambda p: manager.is_compatible(p), PackageDisabler.ignored_packages()),
key=lambda s: s.lower()
)
def on_done(self, manager, package_name):
"""
Quick panel user selection handler - enables the selected package
:param manager:
The package manager instance to use.
:param package_name:
A package name to perform action for
"""
PackageDisabler.reenable_packages({PackageDisabler.ENABLE: package_name})
sublime.status_message('Package %s successfully enabled.' % package_name)