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

Bash adapter #251

Open
arturolinares opened this issue Mar 9, 2024 · 2 comments
Open

Bash adapter #251

arturolinares opened this issue Mar 9, 2024 · 2 comments

Comments

@arturolinares
Copy link

It would be great if there were an adapter for debugging Bash scripts that use this library: https://github.com/rogalmic/vscode-bash-debug

I would also like to know how to create new adapters. Should they live in this package? Is it possible to create a new package that provides new adapters?

Thank you very much for your hard work. This plugin really helps Sublime Text ecosystem :)

@daveleroy
Copy link
Owner

If its for other people to use they should live in this package because there isn't a stable api for adapters to use. For testing and custom adapters you can add them outside the package and they will be picked up.

Here is the current adapters https://github.com/daveleroy/SublimeDebugger/tree/master/modules/adapters you can add to that and import it in the init.py and open a pull request.

Something like the following should get you started.

from . import util
from .. import dap
from .. import core


class Bash(dap.AdapterConfiguration):

	type = 'bashdb'
	docs = 'https://github.com/rogalmic/vscode-bash-debug#vs-code-bash-debug'

	installer = util.GitInstaller (
		type='bashdb',
		repo='rogalmic/vscode-bash-debug'
	)

	async def start(self, log: core.Logger, configuration: dap.ConfigurationExpanded):
		node = await util.get_and_warn_require_node(self.type, log)

		install_path = self.installer.install_path()
		command = [
			node,
			f'{install_path}/extension/out/bashDebug.js'
		]
		return dap.StdioTransport(command)

	async def configuration_resolve(self, configuration: dap.ConfigurationExpanded) -> dap.ConfigurationExpanded:

		defaults = {
			'pathBash': 'bash',
			'pathBashdb': f'{self.installer.install_path()}/extension/bashdb_dir/bashdb',
			'pathBashdbLib': f'{self.installer.install_path()}/extension/bashdb_dir',
			'args': [],
			'env': {},
			'argsString': '',
			'pathCat': 'cat',
			'pathMkfifo': 'mkfifo',
			'pathPkill': 'pkill',
			'cwd': configuration.variables['folder']
		}

		for key, value in defaults.items():
			if not configuration.get(key):
				configuration[key] = value

		return configuration

@daveleroy
Copy link
Owner

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

No branches or pull requests

2 participants