Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bin/opi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class PreserveWhiteSpaceWrapRawTextHelpFormatter(argparse.RawTextHelpFormatter):


def setup_argparser(plugin_manager):
extras = plugin_manager.get_plugin_string(' ' * 2, 'extras')
if extras:
extras = textwrap.dedent('''\
\nThese queries are provided by plugins that are not part of the opi package:
''') + extras

ap = argparse.ArgumentParser(
formatter_class=PreserveWhiteSpaceWrapRawTextHelpFormatter,
description=textwrap.dedent('''\
Expand All @@ -49,7 +55,7 @@ def setup_argparser(plugin_manager):
'''),
epilog=textwrap.dedent('''\
Also these queries (provided by plugins) can be used to install packages from various other vendors:
''') + plugin_manager.get_plugin_string(' ' * 2))
''') + plugin_manager.get_plugin_string(' ' * 2) + extras)

ap.add_argument('query', nargs='*', type=str, help=textwrap.dedent('''\
can be any package name or part of it and will be searched for both at the openSUSE Build Service and Packman.
Expand Down
5 changes: 4 additions & 1 deletion opi/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class BasePlugin:
main_query = ''
description = ''
queries = []
group = ''

@classmethod
def matches(cls, query):
Expand Down Expand Up @@ -38,9 +39,11 @@ def run(self, query):
pass
return True

def get_plugin_string(self, indent=''):
def get_plugin_string(self, indent='', group=''):
plugins = ''
for plugin in self.plugins:
if group != 'all' and plugin.group != group:
continue
description = plugin.description.replace('\n', '\n' + (' ' * 16) + ' ')
plugins += f'{indent}{plugin.main_query:16} {description}\n'
return plugins
17 changes: 17 additions & 0 deletions opi/plugins/netbeans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import opi
from opi.plugins import BasePlugin
from opi import github

class NetBeans(BasePlugin):
main_query = 'netbeans'
description = 'Development environment, tooling platform and application framework'
queries = ['netbeans', 'NetBeans']
group = 'extras'

@classmethod
def run(cls, query):
arch = opi.get_cpu_arch()
github.install_rpm_release('Friends-of-Apache-NetBeans', 'netbeans-installers',
filters=[lambda a: a['name'].endswith(f'{arch}.rpm')],
allow_unsigned=True # no key available
)