简体   繁体   English

来自另一个包的 Atom 包命令

[英]Atom package command from another package

Let's say in my custom Atom package I insert a JSON string into a file.假设在我的自定义 Atom 包中,我将一个 JSON 字符串插入到一个文件中。 After that, I'd like to run the beautify-language-json from atom-beautify package automatically.之后,我想自动运行atom-beautify包中的beautify-language-json

How can I launch this command from my package?如何从我的包中启动此命令?

As described in the API documentation, you can use the dispatch() method for that.如 API 文档中所述,您可以为此使用dispatch()方法。

Example:例子:

const target = atom.views.getView(atom.workspace);
const commandName = 'atom-beautify:beautify-language-json';

atom.commands.dispatch(target, commandName);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM